composer.phar 2.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444
  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. if (!class_exists('Phar')) {
  22. echo 'PHP\'s phar extension is missing. Composer requires it to run. Enable the extension or recompile php without --disable-phar then try again.' . PHP_EOL;
  23. exit(1);
  24. }
  25. Phar::mapPhar('composer.phar');
  26. require 'phar://composer.phar/bin/composer';
  27. __HALT_COMPILER(); ?>
  28. › �������� ���composer.phar����+���src/Composer/Autoload/AutoloadGenerator.php ‚��/ô¥a ‚��°)Š¤������+���src/Composer/Autoload/ClassMapGenerator.phpy��/ô¥ay��[OU¤������(���src/Composer/Autoload/PhpFileCleaner.phpŸ��/ô¥aŸ��I¢Ò¤���������src/Composer/Cache.php†��/ô¥a†��Ÿ®"¤������%���src/Composer/Command/AboutCommand.php7��/ô¥a7��°, `¤������'���src/Composer/Command/ArchiveCommand.phpÆ��/ô¥aÆ��PϤ������$���src/Composer/Command/BaseCommand.phpL��/ô¥aL��ÜÌÄÛ¤������.���src/Composer/Command/BaseDependencyCommand.phpŸ��/ô¥aŸ��c Qç¤������1���src/Composer/Command/CheckPlatformReqsCommand.phpÄ��/ô¥aÄ��À¯ø¤������*���src/Composer/Command/ClearCacheCommand.phpù��/ô¥aù��w¯Ȥ������&���src/Composer/Command/ConfigCommand.phpÑX��/ô¥aÑX��/ÎѤ������-���src/Composer/Command/CreateProjectCommand.php'C��/ô¥a'C��¬³D¤������'���src/Composer/Command/DependsCommand.php’��/ô¥a’��&Ž­¤������(���src/Composer/Command/DiagnoseCommand.php²M��/ô¥a²M��äXÅœ¤������,���src/Composer/Command/DumpAutoloadCommand.phpü��/ô¥aü��!¼IO¤������$���src/Composer/Command/ExecCommand.php¢��/ô¥a¢��ÂíÎÔ¤������$���src/Composer/Command/FundCommand.php3��/ô¥a3��Òð‰X¤������&���src/Composer/Command/GlobalCommand.phpj
  29. ��/ô¥aj
  30. ��sD¤¤������$���src/Composer/Command/HomeCommand.php ��/ô¥a ��¨S?Y¤������$���src/Composer/Command/InitCommand.phpnp��/ô¥anp���.¡Á¤������'���src/Composer/Command/InstallCommand.php&��/ô¥a&��ôN4ä������(���src/Composer/Command/LicensesCommand.php:��/ô¥a:��±W¬Ü¤������(���src/Composer/Command/OutdatedCommand.php� ��/ô¥a� �� ñwÓ¤������)���src/Composer/Command/ProhibitsCommand.php<��/ô¥a<��I¸3¤������)���src/Composer/Command/ReinstallCommand.php©��/ô¥a©��þS!ö¤������&���src/Composer/Command/RemoveCommand.phpÞ)��/ô¥aÞ)��(6"ä¤������'���src/Composer/Command/RequireCommand.phpôB��/ô¥aôB��xŠï³¤������)���src/Composer/Command/RunScriptCommand.php¦��/ô¥a¦��PšD¤������+���src/Composer/Command/ScriptAliasCommand.php»��/ô¥a»��W–ù»¤������&���src/Composer/Command/SearchCommand.php
  31. ��/ô¥a
  32. ��È$ÊФ������*���src/Composer/Command/SelfUpdateCommand.phpµE��/ô¥aµE��¹p¤������$���src/Composer/Command/ShowCommand.php¾Ž��/ô¥a¾Ž��W¦ÒL¤������&���src/Composer/Command/StatusCommand.phpé��/ô¥aé��å1‘¤������(���src/Composer/Command/SuggestsCommand.php› ��/ô¥a› ��MÖ­¤������&���src/Composer/Command/UpdateCommand.php#5��/ô¥a#5��0iV¤������(���src/Composer/Command/ValidateCommand.php���/ô¥a���å¯()¤���������src/Composer/Composer.php' ��/ô¥a' ��Áµú¤���������src/Composer/Config.phpÛ'��/ô¥aÛ'��ÁÁœ¾¤������-���src/Composer/Config/ConfigSourceInterface.php/��/ô¥a/��פ������(���src/Composer/Config/JsonConfigSource.php™��/ô¥a™��ÓÀV¤������$���src/Composer/Console/Application.phpU>��/ô¥aU>��sˆöä¤������*���src/Composer/Console/GithubActionError.php���/ô¥a���çʤ������,���src/Composer/Console/HtmlOutputFormatter.php{��/ô¥a{��ñ«NW¤������-���src/Composer/DependencyResolver/Decisions.php©��/ô¥a©��0´­Û¤������1���src/Composer/DependencyResolver/DefaultPolicy.phpú��/ô¥aú��ŸÍI´¤������/���src/Composer/DependencyResolver/GenericRule.phpf��/ô¥af���’¼æ¤������8���src/Composer/DependencyResolver/LocalRepoTransaction.php¤��/ô¥a¤��ƒ #¤������3���src/Composer/DependencyResolver/LockTransaction.php ��/ô¥a ��›]/¤������5���src/Composer/DependencyResolver/MultiConflictRule.phpõ��/ô¥aõ��ÚLm›¤������>���src/Composer/DependencyResolver/Operation/InstallOperation.php»��/ô¥a»��ïF‡ã¤������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.phpß��/ô¥aß��=Ù÷À¤������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.phpå��/ô¥aå��‡°¸/¤������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpÚ���/ô¥aÚ���Qâè¤������=���src/Composer/DependencyResolver/Operation/SolverOperation.php��/ô¥a��mÑa¤������@���src/Composer/DependencyResolver/Operation/UninstallOperation.php£��/ô¥a£�� Y<¤������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phpK��/ô¥aK��ò;!¤������3���src/Composer/DependencyResolver/PolicyInterface.phpm��/ô¥am��¦²ù&¤������(���src/Composer/DependencyResolver/Pool.php¬��/ô¥a¬��yÚ"¤������/���src/Composer/DependencyResolver/PoolBuilder.php;3��/ô¥a;3��ø T¤������+���src/Composer/DependencyResolver/Problem.phpð?��/ô¥að?��ì—�¤������+���src/Composer/DependencyResolver/Request.php&��/ô¥a&��ÍŠcþ¤������(���src/Composer/DependencyResolver/Rule.php‡+��/ô¥a‡+��æõÛ¤������1���src/Composer/DependencyResolver/Rule2Literals.phpË��/ô¥aË��†­F¤������+���src/Composer/DependencyResolver/RuleSet.phpƒ ��/ô¥aƒ ��
  33. K.x¤������4���src/Composer/DependencyResolver/RuleSetGenerator.php)��/ô¥a)��õ)ð=¤������3���src/Composer/DependencyResolver/RuleSetIterator.php ��/ô¥a ��•Ÿƒj¤������2���src/Composer/DependencyResolver/RuleWatchChain.phpU��/ô¥aU��B#¤������2���src/Composer/DependencyResolver/RuleWatchGraph.phpS ��/ô¥aS ��Uؤ������1���src/Composer/DependencyResolver/RuleWatchNode.php<��/ô¥a<��¯T†2¤������*���src/Composer/DependencyResolver/Solver.php£7��/ô¥a£7��î­ò½¤������6���src/Composer/DependencyResolver/SolverBugException.phpœ��/ô¥aœ��^Hᕤ������;���src/Composer/DependencyResolver/SolverProblemsException.phpµ��/ô¥aµ��Iƒ¬ê¤������/���src/Composer/DependencyResolver/Transaction.phpÿ��/ô¥aÿ��…âߧ¤������-���src/Composer/Downloader/ArchiveDownloader.php��/ô¥a��Šbˆå¤������1���src/Composer/Downloader/ChangeReportInterface.phpÌ���/ô¥aÌ���¯à¨¿¤������+���src/Composer/Downloader/DownloadManager.phpá��/ô¥aá��Õ´s¤������/���src/Composer/Downloader/DownloaderInterface.php ��/ô¥a ��_y¶¤������3���src/Composer/Downloader/DvcsDownloaderInterface.phpÑ���/ô¥aÑ���&Áœ¿¤������*���src/Composer/Downloader/FileDownloader.phpÙ.��/ô¥aÙ.���þ^4¤������/���src/Composer/Downloader/FilesystemException.php��/ô¥a��×^x¤������,���src/Composer/Downloader/FossilDownloader.phpA ��/ô¥aA ��çã�J¤������)���src/Composer/Downloader/GitDownloader.php @��/ô¥a @��žÇf÷¤������*���src/Composer/Downloader/GzipDownloader.php��/ô¥a��úÄ›¤������(���src/Composer/Downloader/HgDownloader.php
  34. ��/ô¥a
  35. ��Ôƒ0,¤������8���src/Composer/Downloader/MaxFileSizeExceededException.phps���/ô¥as���Ù¢ ñ¤������*���src/Composer/Downloader/PathDownloader.phpg��/ô¥ag��Óva¥¤������.���src/Composer/Downloader/PerforceDownloader.phpˆ��/ô¥aˆ��¥‡Ø•¤������*���src/Composer/Downloader/PharDownloader.phpI��/ô¥aI��Äk0ò¤������)���src/Composer/Downloader/RarDownloader.php6��/ô¥a6��ÏÐFõ¤������)���src/Composer/Downloader/SvnDownloader.php��/ô¥a��xy
  36. 6¤������)���src/Composer/Downloader/TarDownloader.phpG��/ô¥aG��/P]¤������.���src/Composer/Downloader/TransportException.php&��/ô¥a&��xc# ¤������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpÔ���/ô¥aÔ���`§ôö¤������)���src/Composer/Downloader/VcsDownloader.phpr��/ô¥ar��6®t¥¤������(���src/Composer/Downloader/XzDownloader.phpL��/ô¥aL��b]¾Û¤������)���src/Composer/Downloader/ZipDownloader.php¾��/ô¥a¾��tk) ¤������&���src/Composer/EventDispatcher/Event.php¢��/ô¥a¢��ÉNÇŒ¤������0���src/Composer/EventDispatcher/EventDispatcher.phpï2��/ô¥aï2��ô2÷Ù¤������9���src/Composer/EventDispatcher/EventSubscriberInterface.php©���/ô¥a©���h·0¤������9���src/Composer/EventDispatcher/ScriptExecutionException.phpv���/ô¥av���wZ8S¤������9���src/Composer/Exception/IrrecoverableDownloadException.phpv���/ô¥av���DM½y¤������)���src/Composer/Exception/NoSslException.phph���/ô¥ah���ˆdñÓ¤���������src/Composer/Factory.php E��/ô¥a E��ØMu”¤���������src/Composer/IO/BaseIO.php¦��/ô¥a¦��²A¤���������src/Composer/IO/BufferIO.phpí��/ô¥aí��/2—¼¤���������src/Composer/IO/ConsoleIO.phpZ��/ô¥aZ���;uì¤���������src/Composer/IO/IOInterface.phpè��/ô¥aè�� 6s¤���������src/Composer/IO/NullIO.php¿��/ô¥a¿��óZ·¤���������src/Composer/Installer.phpuy��/ô¥auy��Bà ù¤������*���src/Composer/Installer/BinaryInstaller.phps��/ô¥as��ôæ¤������2���src/Composer/Installer/BinaryPresenceInterface.phpÍ���/ô¥aÍ���“ï`U¤������.���src/Composer/Installer/InstallationManager.php¶5��/ô¥a¶5��j” ©¤������)���src/Composer/Installer/InstallerEvent.phpå��/ô¥aå��ÎE N¤������*���src/Composer/Installer/InstallerEvents.php…���/ô¥a…���nÜ<Á¤������-���src/Composer/Installer/InstallerInterface.phpI��/ô¥aI��µªØ\¤������+���src/Composer/Installer/LibraryInstaller.php”��/ô¥a”��ʬx7¤������/���src/Composer/Installer/MetapackageInstaller.php—��/ô¥a—��‰º@¥¤������(���src/Composer/Installer/NoopInstaller.php&��/ô¥a&��.¶¤������'���src/Composer/Installer/PackageEvent.php–��/ô¥a–��=¯³X¤������(���src/Composer/Installer/PackageEvents.php¸��/ô¥a¸��dbØs¤������*���src/Composer/Installer/PluginInstaller.php¯
  37. ��/ô¥a¯
  38. ��9òs¤������+���src/Composer/Installer/ProjectInstaller.phpl��/ô¥al��f£ƒ¤������4���src/Composer/Installer/SuggestedPackagesReporter.phpó��/ô¥aó��6s ¤���������src/Composer/Json/JsonFile.php™��/ô¥a™��LÔOZ¤������#���src/Composer/Json/JsonFormatter.phpS��/ô¥aS��†e¤������%���src/Composer/Json/JsonManipulator.php 8��/ô¥a 8��û¨.¤������-���src/Composer/Json/JsonValidationException.phpo��/ô¥ao��T3ÌI¤������%���src/Composer/Package/AliasPackage.phpµ��/ô¥aµ��Zdô[¤������7���src/Composer/Package/Archiver/ArchivableFilesFilter.php(��/ô¥a(��U?Ø0¤������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpÿ��/ô¥aÿ��ás%*¤������0���src/Composer/Package/Archiver/ArchiveManager.phpú��/ô¥aú��}Ô~´¤������3���src/Composer/Package/Archiver/ArchiverInterface.php��/ô¥a��¨·š“¤������3���src/Composer/Package/Archiver/BaseExcludeFilter.php~��/ô¥a~��!Ê p¤������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php��/ô¥a��‹SZ0¤������2���src/Composer/Package/Archiver/GitExcludeFilter.phpr��/ô¥ar��3‘Mh¤������1���src/Composer/Package/Archiver/HgExcludeFilter.php
  39. ��/ô¥a
  40. ��&ðm(¤������.���src/Composer/Package/Archiver/PharArchiver.php…��/ô¥a…��µôTL¤������-���src/Composer/Package/Archiver/ZipArchiver.phpà��/ô¥aà��År¬¤������$���src/Composer/Package/BasePackage.php•��/ô¥a•��“˜�q¤������*���src/Composer/Package/Comparer/Comparer.phpÅ��/ô¥aÅ��Le„´¤������-���src/Composer/Package/CompleteAliasPackage.phpˆ ��/ô¥aˆ ��K�W¤������(���src/Composer/Package/CompletePackage.phpR ��/ô¥aR ��µ2®¤������1���src/Composer/Package/CompletePackageInterface.phpÙ��/ô¥aÙ��¾Bø$¤������+���src/Composer/Package/Dumper/ArrayDumper.php ��/ô¥a ��ôQ!¤���������src/Composer/Package/Link.phpo��/ô¥ao��\¤ @¤������+���src/Composer/Package/Loader/ArrayLoader.phpS*��/ô¥aS*��61¤������7���src/Composer/Package/Loader/InvalidPackageException.phpV��/ô¥aV��D¤¤������*���src/Composer/Package/Loader/JsonLoader.php��/ô¥a��Àµo¤������/���src/Composer/Package/Loader/LoaderInterface.php€��/ô¥a€��Ì&<l¤������1���src/Composer/Package/Loader/RootPackageLoader.phpI��/ô¥aI��òGS$¤������5���src/Composer/Package/Loader/ValidatingArrayLoader.php=I��/ô¥a=I��í¥Rª¤���������src/Composer/Package/Locker.phpZ%��/ô¥aZ%��U`íu¤������ ���src/Composer/Package/Package.php¸��/ô¥a¸��©"%¤������)���src/Composer/Package/PackageInterface.phpã ��/ô¥aã ��ka ¤������)���src/Composer/Package/RootAliasPackage.php* ��/ô¥a* ��‰/�†¤������$���src/Composer/Package/RootPackage.phpC��/ô¥aC��•d¥a¤������-���src/Composer/Package/RootPackageInterface.phpí��/ô¥aí�� Hèm¤������0���src/Composer/Package/Version/StabilityFilter.phpï��/ô¥aï��'o£ƒ¤������/���src/Composer/Package/Version/VersionGuesser.phpû$��/ô¥aû$��N7_¿¤������.���src/Composer/Package/Version/VersionParser.php•��/ô¥a•��»ueS¤������0���src/Composer/Package/Version/VersionSelector.php1��/ô¥a1��…I¥ˆ¤������&���src/Composer/Platform/HhvmDetector.php ��/ô¥a ��ÈL¶¤������!���src/Composer/Platform/Runtime.phpK��/ô¥aK��Aä³
  41. ¤������!���src/Composer/Platform/Version.php±��/ô¥a±��öû¤������-���src/Composer/Plugin/Capability/Capability.phpW���/ô¥aW���æ_¨1¤������2���src/Composer/Plugin/Capability/CommandProvider.php—���/ô¥a—���ûOâ>¤���������src/Composer/Plugin/Capable.php���/ô¥a���Æq+¤������$���src/Composer/Plugin/CommandEvent.phpâ��/ô¥aâ��³ÆÇW¤������$���src/Composer/Plugin/PluginEvents.phpe��/ô¥ae��*U~r¤������'���src/Composer/Plugin/PluginInterface.php”��/ô¥a”��hÍ%;¤������%���src/Composer/Plugin/PluginManager.php„0��/ô¥a„0��ˆÏúj¤������-���src/Composer/Plugin/PostFileDownloadEvent.phpT��/ô¥aT��/œœ3¤������*���src/Composer/Plugin/PreCommandRunEvent.phpõ��/ô¥aõ��:ðd¤������,���src/Composer/Plugin/PreFileDownloadEvent.php5��/ô¥a5��aÕ0z¤������*���src/Composer/Plugin/PrePoolCreateEvent.phpR��/ô¥aR��ÿcµ¤������4���src/Composer/Question/StrictConfirmationQuestion.php ��/ô¥a ��4äÛ¤������+���src/Composer/Repository/ArrayRepository.phpV��/ô¥aV��ÇI.ò¤������.���src/Composer/Repository/ArtifactRepository.php" ��/ô¥a" ��FŒž8¤������.���src/Composer/Repository/ComposerRepository.phpß”��/ô¥aß”��ý&̤������/���src/Composer/Repository/CompositeRepository.php¥ ��/ô¥a¥ ��ü­¯¤������;���src/Composer/Repository/ConfigurableRepositoryInterface.phpˆ���/ô¥aˆ���Ùs ¤������0���src/Composer/Repository/FilesystemRepository.php��/ô¥a��ÁI2¹¤������,���src/Composer/Repository/FilterRepository.phpá ��/ô¥aá ��îЧE¤������4���src/Composer/Repository/InstalledArrayRepository.php1��/ô¥a1��]«×¤������9���src/Composer/Repository/InstalledFilesystemRepository.php1��/ô¥a1��y&êͤ������/���src/Composer/Repository/InstalledRepository.php+��/ô¥a+��Òkפ������8���src/Composer/Repository/InstalledRepositoryInterface.php¥���/ô¥a¥���Ã%¤������6���src/Composer/Repository/InvalidRepositoryException.phpn���/ô¥an���à“똤������/���src/Composer/Repository/LockArrayRepository.php¤���/ô¥a¤���E™†S¤������-���src/Composer/Repository/PackageRepository.phpÒ��/ô¥aÒ��^Y¤������*���src/Composer/Repository/PathRepository.php)��/ô¥a)��¦€q€¤������*���src/Composer/Repository/PearRepository.phpî���/ô¥aî���‹0‚Ǥ������.���src/Composer/Repository/PlatformRepository.phpcJ��/ô¥acJ��ë 6¤������-���src/Composer/Repository/RepositoryFactory.php®��/ô¥a®��¨ šN¤������/���src/Composer/Repository/RepositoryInterface.php:��/ô¥a:��&Öó4¤������-���src/Composer/Repository/RepositoryManager.php ��/ô¥a ��‹¶‘¤������7���src/Composer/Repository/RepositorySecurityException.phpo���/ô¥ao���pÕ«ª¤������)���src/Composer/Repository/RepositorySet.phpÌ��/ô¥aÌ��OÏïϤ������1���src/Composer/Repository/RootPackageRepository.php@��/ô¥a@��X¦Ž¤������/���src/Composer/Repository/Vcs/BitbucketDriver.php› ��/ô¥a› ��ß{§)¤������,���src/Composer/Repository/Vcs/FossilDriver.php—��/ô¥a—��Î ‹¤������2���src/Composer/Repository/Vcs/GitBitbucketDriver.phpf��/ô¥af��¸°û¤������)���src/Composer/Repository/Vcs/GitDriver.php���/ô¥a���®:P¤������,���src/Composer/Repository/Vcs/GitHubDriver.phpF5��/ô¥aF5��-+ÞÔ¤������,���src/Composer/Repository/Vcs/GitLabDriver.php×,��/ô¥a×,��ŒòXb¤������1���src/Composer/Repository/Vcs/HgBitbucketDriver.php`��/ô¥a`��æKñœ¤������(���src/Composer/Repository/Vcs/HgDriver.php$��/ô¥a$��ó�w¤������.���src/Composer/Repository/Vcs/PerforceDriver.php
  42. ��/ô¥a
  43. ��ßÙ ”¤������)���src/Composer/Repository/Vcs/SvnDriver.phpž��/ô¥až��ßz#Ǥ������)���src/Composer/Repository/Vcs/VcsDriver.phpr
  44. ��/ô¥ar
  45. ��¥~u¤������2���src/Composer/Repository/Vcs/VcsDriverInterface.phpý��/ô¥aý�� Î¤������)���src/Composer/Repository/VcsRepository.php¸2��/ô¥a¸2��’ùÜ°¤������1���src/Composer/Repository/VersionCacheInterface.php”���/ô¥a”���A?Rï¤������3���src/Composer/Repository/WritableArrayRepository.phpO��/ô¥aO��‰Ýê¤������7���src/Composer/Repository/WritableRepositoryInterface.phpY��/ô¥aY��l÷A«¤���������src/Composer/Script/Event.phpš��/ô¥aš��Óô©¤������$���src/Composer/Script/ScriptEvents.phpÜ��/ô¥aÜ��ÆíÁ¤������ ���src/Composer/SelfUpdate/Keys.php¡��/ô¥a¡��Ômw8¤������$���src/Composer/SelfUpdate/Versions.phpK��/ô¥aK��üüç¤������ ���src/Composer/Util/AuthHelper.php×��/ô¥a×��ª¢«–¤���������src/Composer/Util/Bitbucket.phpè��/ô¥aè��9´Âå¤������$���src/Composer/Util/ComposerMirror.phpQ��/ô¥aQ��”1M¤������%���src/Composer/Util/ConfigValidator.php2��/ô¥a2��ËÜ?¤������"���src/Composer/Util/ErrorHandler.php|��/ô¥a|��µòi¤������ ���src/Composer/Util/Filesystem.phpÁ9��/ô¥aÁ9��¿©³¤���������src/Composer/Util/Git.php 5��/ô¥a 5��ÕÑ´e¤���������src/Composer/Util/GitHub.phpÿ��/ô¥aÿ��–Ú�>¤���������src/Composer/Util/GitLab.phpƒ��/ô¥aƒ��eº«¤���������src/Composer/Util/Hg.php��/ô¥a��Ò˜C%¤������)���src/Composer/Util/Http/CurlDownloader.php¸A��/ô¥a¸A��;˜X¤������'���src/Composer/Util/Http/CurlResponse.phpg��/ô¥ag��·ùÿ§¤������&���src/Composer/Util/Http/ProxyHelper.phpM
  46. ��/ô¥aM
  47. ��ÝâM¦¤������'���src/Composer/Util/Http/ProxyManager.php¡
  48. ��/ô¥a¡
  49. ��öîQð¤������'���src/Composer/Util/Http/RequestProxy.php��/ô¥a��ÁS°¤������#���src/Composer/Util/Http/Response.phpe��/ô¥ae��,잆¤������$���src/Composer/Util/HttpDownloader.phph&��/ô¥ah&��Ò'Z|¤���������src/Composer/Util/IniHelper.phph��/ô¥ah��;FP¤���������src/Composer/Util/Loop.php¶��/ô¥a¶��Ô·}„¤������&���src/Composer/Util/MetadataMinifier.php*��/ô¥a*��hÛ/~¤������$���src/Composer/Util/NoProxyPattern.phpz��/ô¥az��Š"
  50. ã¤������#���src/Composer/Util/PackageSorter.phpÛ��/ô¥aÛ��TÆjþ¤���������src/Composer/Util/Perforce.phpR3��/ô¥aR3�� %ð¤���������src/Composer/Util/Platform.phpÏ ��/ô¥aÏ ��‚ܹr¤������%���src/Composer/Util/ProcessExecutor.phpœ��/ô¥aœ��ºy²Ç¤������&���src/Composer/Util/RemoteFilesystem.phpJN��/ô¥aJN��SG¬¤���������src/Composer/Util/Silencer.phpê��/ô¥aê��pDà¤������*���src/Composer/Util/StreamContextFactory.phpq��/ô¥aq��ï‹5Ž¤���������src/Composer/Util/Svn.php!��/ô¥a!���Z1J¤������ ���src/Composer/Util/SyncHelper.php;��/ô¥a;��*î
  51. ‹¤���������src/Composer/Util/Tar.phpb��/ô¥ab��å]–¤���������src/Composer/Util/TlsHelper.phpc
  52. ��/ô¥ac
  53. ��s83…¤���������src/Composer/Util/Url.php ��/ô¥a ��?9£¤���������src/Composer/Util/Zip.phpæ��/ô¥aæ��¸+¤���������src/bootstrap.php¼��/ô¥a¼��@’H*¤������%���src/Composer/Autoload/ClassLoader.phpÁ>��/ô¥aÁ>��H[ð¤������"���src/Composer/InstalledVersions.php�:��/ô¥a�:��TðÓ"¤������#���res/composer-repository-schema.jsonñ��/ô¥añ��|0à„¤���������res/composer-schema.json!®��/ô¥a!®��Ìñ-‹¤���������vendor/autoload.php‚���/ô¥a‚���·Ñî¤���������vendor/composer/ClassLoader.php\��/ô¥a\��ÜZuœ¤������%���vendor/composer/InstalledVersions.phpi��/ô¥ai��û$Ø.¤������%���vendor/composer/autoload_classmap.phpµ���/ô¥aµ���x’ý»¤������"���vendor/composer/autoload_files.phpŒ��/ô¥aŒ��� ¤������'���vendor/composer/autoload_namespaces.php¢���/ô¥a¢����R7c¤������!���vendor/composer/autoload_psr4.phpP��/ô¥aP��à¢åU¤������!���vendor/composer/autoload_real.phpc��/ô¥ac��ÃÎqš¤������#���vendor/composer/autoload_static.phpG ��/ô¥aG ��òe¤������!���vendor/composer/ca-bundle/LICENSE��/ô¥a��G _¤������(���vendor/composer/ca-bundle/res/cacert.pemÁ,�/ô¥aÁ,�½_~Ž¤������*���vendor/composer/ca-bundle/src/CaBundle.php•$��/ô¥a•$��ÛnÓ¤���������vendor/composer/installed.php��/ô¥a��‘{&ù¤������)���vendor/composer/metadata-minifier/LICENSE��/ô¥a��½£ëǤ������:���vendor/composer/metadata-minifier/src/MetadataMinifier.phpÐ��/ô¥aÐ��Â0&À¤���������vendor/composer/semver/LICENSE��/ô¥a��ÇSRm¤������)���vendor/composer/semver/src/Comparator.php��/ô¥a��^_E“¤������/���vendor/composer/semver/src/CompilingMatcher.phpå��/ô¥aå��»ˆgm¤������/���vendor/composer/semver/src/Constraint/Bound.phpw��/ô¥aw��W4]W¤������4���vendor/composer/semver/src/Constraint/Constraint.phpø��/ô¥aø��’‹ˆ½¤������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php¡��/ô¥a¡��Ž5´y¤������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php¯��/ô¥a¯��²Eú¤������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÉ��/ô¥aÉ��֯خ¤������9���vendor/composer/semver/src/Constraint/MultiConstraint.phpŠ��/ô¥aŠ��ÍÕĤ������'���vendor/composer/semver/src/Interval.phpæ��/ô¥aæ��=[i¤������(���vendor/composer/semver/src/Intervals.php¤+��/ô¥a¤+��@1º«¤������%���vendor/composer/semver/src/Semver.phpù��/ô¥aù��á-i¤������,���vendor/composer/semver/src/VersionParser.php†,��/ô¥a†,��*eÏó¤������%���vendor/composer/spdx-licenses/LICENSE��/ô¥a��ÇSRm¤������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json¸ ��/ô¥a¸ ��Â4DC¤������4���vendor/composer/spdx-licenses/res/spdx-licenses.json¾��/ô¥a¾��eÇõ̤������2���vendor/composer/spdx-licenses/src/SpdxLicenses.php{��/ô¥a{��ž “¤������&���vendor/composer/xdebug-handler/LICENSE+��/ô¥a+��Öã@T¤������0���vendor/composer/xdebug-handler/src/PhpConfig.php'��/ô¥a'��Ps²¤������.���vendor/composer/xdebug-handler/src/Process.php!��/ô¥a!��¶½G%¤������-���vendor/composer/xdebug-handler/src/Status.phpÉ
  54. ��/ô¥aÉ
  55. ��¤È
  56. ¤������4���vendor/composer/xdebug-handler/src/XdebugHandler.php¼&��/ô¥a¼&��…r#µ¤������(���vendor/justinrainbow/json-schema/LICENSE"��/ô¥a"�� |»™¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ��/ô¥a¡ ��†wÌl¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.phpƒ
  57. ��/ô¥aƒ
  58. ��ž¸=š¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.phpÁ ��/ô¥aÁ ��–PFF¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼��/ô¥a¼��ÿ Qœ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php\��/ô¥a\��_}ý¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpà ��/ô¥aà ��ë’_”¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.phps��/ô¥as��d Þ¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.phpƒ ��/ô¥aƒ ��e� ¨¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php·��/ô¥a·��%l¬ö¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php& ��/ô¥a& ��78÷¬¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.phpz��/ô¥az��ùfÅ~¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa��/ô¥aa�� qä������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php—��/ô¥a—��4~¾ ¤������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰��/ô¥a‰��“µ+j¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php��/ô¥a��ª%}¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php,"��/ô¥a,"��‰-¤������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè��/ô¥aè��{N–¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI���/ô¥aI���%|°¤������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•���/ô¥a•���‹àG¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl���/ô¥al���A!Lפ������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl���/ô¥al���è2÷þ¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu���/ô¥au���=hç¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw���/ô¥aw���N-ò[¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ��/ô¥aÞ��\¸
  59. ¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo���/ô¥ao���píÛù¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…���/ô¥a…���%…—¤������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€���/ô¥a€���u-#1¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj���/ô¥aj���å>�¤������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf���/ô¥af���¬¤„þ¤������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ��/ô¥aþ��M�„õ¤������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ��/ô¥a ��f4÷³¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php“ ��/ô¥a“ ��&zß^¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��/ô¥a��oŠ+}¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá���/ô¥aá���[þA�¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php£��/ô¥a£��Ç’ô¦¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php ��/ô¥a ��£Á¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,��/ô¥a,��1•5þ¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®���/ô¥a®���ÿ‹Áå¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ��/ô¥a ��æP¤������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php@��/ô¥a@��5Î3¤������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ���/ô¥aƒ���J€¤������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…���/ô¥a…���íæe¤������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phps��/ô¥as��ßÁ‘#¤���������vendor/psr/log/LICENSE?��/ô¥a?��„ù ¤������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��/ô¥a;��ñ>3[¤������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���/ô¥a`��� ˆX1¤������#���vendor/psr/log/Psr/Log/LogLevel.phpû���/ô¥aû���jðñ8¤������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���/ô¥a|���$£ˆ¤������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���/ô¥a§���T½úB¤������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ��/ô¥aÈ��šx¤������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk��/ô¥ak��£}‰’¤������%���vendor/psr/log/Psr/Log/NullLogger.phpŸ���/ô¥aŸ����Xóª¤������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp���/ô¥ap���Τ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ��/ô¥a ��$/Ò¤������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<��/ô¥a<��þ(åI¤���������vendor/react/promise/LICENSE'��/ô¥a'��¶-º„¤������F���vendor/react/promise/src/React/Promise/CancellablePromiseInterface.php����/ô¥a���� ƒ<�¤������3���vendor/react/promise/src/React/Promise/Deferred.phpð ��/ô¥að ��o(ퟤ������:���vendor/react/promise/src/React/Promise/DeferredPromise.phpÇ��/ô¥aÇ��º`W¤������;���vendor/react/promise/src/React/Promise/DeferredResolver.phpÃ��/ô¥aÃ��7Ëu¤������;���vendor/react/promise/src/React/Promise/FulfilledPromise.phpÍ��/ô¥aÍ��´–U¤������6���vendor/react/promise/src/React/Promise/LazyPromise.php��/ô¥a��Š»¤������2���vendor/react/promise/src/React/Promise/Promise.php��/ô¥a��º6Jµ¤������;���vendor/react/promise/src/React/Promise/PromiseInterface.phpŸ���/ô¥aŸ��� ½¨n¤������<���vendor/react/promise/src/React/Promise/PromisorInterface.php\���/ô¥a\���Wèêà¤������:���vendor/react/promise/src/React/Promise/RejectedPromise.php¾��/ô¥a¾��fC¿¤������<���vendor/react/promise/src/React/Promise/ResolverInterface.php¼���/ô¥a¼���û �O¤������/���vendor/react/promise/src/React/Promise/Util.phpè���/ô¥aè���Ëý$:¤������/���vendor/react/promise/src/React/Promise/When.phpÇ��/ô¥aÇ��¤o¤������4���vendor/react/promise/src/React/Promise/functions.phpÐ ��/ô¥aÐ ��!³O¤������<���vendor/react/promise/src/React/Promise/functions_include.php\���/ô¥a\���1…‰^¤���������vendor/seld/jsonlint/LICENSE$��/ô¥a$��4:‡~¤������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.phpk��/ô¥ak��Zù¶Ã¤������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php62��/ô¥a62��28ˤ������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php#��/ô¥a#��Úá@,¤������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php%��/ô¥a%��`a„|¤������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���/ô¥a>���ÿqŸŸ¤���������vendor/seld/phar-utils/LICENSE$��/ô¥a$��š,M§¤������%���vendor/seld/phar-utils/src/Linter.phpÍ��/ô¥aÍ��H:›¤������)���vendor/seld/phar-utils/src/Timestamps.phpÈ ��/ô¥aÈ ��ÿ4©¤������&���vendor/symfony/console/Application.php+X��/ô¥a+X��«­yX¤������*���vendor/symfony/console/Command/Command.phpä"��/ô¥aä"���¤Ê¤������.���vendor/symfony/console/Command/HelpCommand.phpØ��/ô¥aØ��¦Ú-:¤������.���vendor/symfony/console/Command/ListCommand.phpZ��/ô¥aZ��»w`¤������(���vendor/symfony/console/ConsoleEvents.phpé���/ô¥aé���RÛÔe¤������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÏ��/ô¥aÏ��<ŽUî¤������0���vendor/symfony/console/Descriptor/Descriptor.php���/ô¥a���¿N•¤������9���vendor/symfony/console/Descriptor/DescriptorInterface.phpü���/ô¥aü���±Qµ¤������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpÜ ��/ô¥aÜ ��*û�ɤ������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.php¶��/ô¥a¶��·Ô;ݤ������4���vendor/symfony/console/Descriptor/TextDescriptor.php·��/ô¥a·��c“q€¤������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��/ô¥a��b{<¤������4���vendor/symfony/console/Event/ConsoleCommandEvent.php°��/ô¥a°��!�Ȥ������-���vendor/symfony/console/Event/ConsoleEvent.phpÅ��/ô¥aÅ��ÒxÛ\¤������6���vendor/symfony/console/Event/ConsoleExceptionEvent.php��/ô¥a��á2é¤������6���vendor/symfony/console/Event/ConsoleTerminateEvent.phpz��/ô¥az��³,îL¤������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÔ��/ô¥aÔ��È÷ L¤������7���vendor/symfony/console/Exception/ExceptionInterface.phpf���/ô¥af���¡ABª¤������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���/ô¥a¦���Ö̽Z¤������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���/ô¥a¦���Ë×H¤������3���vendor/symfony/console/Exception/LogicException.php’���/ô¥a’���ÍO\e¤������5���vendor/symfony/console/Exception/RuntimeException.php–���/ô¥a–���Ùí,6¤������4���vendor/symfony/console/Formatter/OutputFormatter.php3��/ô¥a3��àפ������=���vendor/symfony/console/Formatter/OutputFormatterInterface.phpŒ��/ô¥aŒ��òññÀ¤������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpF��/ô¥aF��𦴤������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php„��/ô¥a„��÷½G¤������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.php@��/ô¥a@��G¨ýU¤������6���vendor/symfony/console/Helper/DebugFormatterHelper.phpy��/ô¥ay��Ì8ÆФ������2���vendor/symfony/console/Helper/DescriptorHelper.phpw��/ô¥aw��|¦C¤������.���vendor/symfony/console/Helper/DialogHelper.phpð��/ô¥að��ÔÈ7¤������1���vendor/symfony/console/Helper/FormatterHelper.phpd��/ô¥ad��§×,¸¤������(���vendor/symfony/console/Helper/Helper.php©��/ô¥a©��Õ'ƒ±¤������1���vendor/symfony/console/Helper/HelperInterface.phpå���/ô¥aå���Š ¤������+���vendor/symfony/console/Helper/HelperSet.phpÊ��/ô¥aÊ��áÏW"¤������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��/ô¥ac��Ìøƒ¤������/���vendor/symfony/console/Helper/ProcessHelper.phpÓ ��/ô¥aÓ ��©w‚R¤������-���vendor/symfony/console/Helper/ProgressBar.phpc%��/ô¥ac%��C&w¤������0���vendor/symfony/console/Helper/ProgressHelper.phpY��/ô¥aY��R!�/¤������3���vendor/symfony/console/Helper/ProgressIndicator.phpM��/ô¥aM��ü�‡¤������0���vendor/symfony/console/Helper/QuestionHelper.php[��/ô¥a[��¯6}ñ¤������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php•
  60. ��/ô¥a•
  61. ���]~R¤������'���vendor/symfony/console/Helper/Table.php¼*��/ô¥a¼*��fêý!¤������+���vendor/symfony/console/Helper/TableCell.php€��/ô¥a€��‹ƒ[¤������-���vendor/symfony/console/Helper/TableHelper.php ��/ô¥a ��›uô™¤������0���vendor/symfony/console/Helper/TableSeparator.phpÊ���/ô¥aÊ���az¤������,���vendor/symfony/console/Helper/TableStyle.php
  62. ��/ô¥a
  63. ��_ÍI"¤������*���vendor/symfony/console/Input/ArgvInput.php��/ô¥a��ªèB-¤������+���vendor/symfony/console/Input/ArrayInput.php) ��/ô¥a) ��¥ÑC¤������&���vendor/symfony/console/Input/Input.php£ ��/ô¥a£ ��f¡?¤������.���vendor/symfony/console/Input/InputArgument.php��/ô¥a��D £¤������4���vendor/symfony/console/Input/InputAwareInterface.php˜���/ô¥a˜���­O°¤������0���vendor/symfony/console/Input/InputDefinition.php†��/ô¥a†��¤U)¤¤������/���vendor/symfony/console/Input/InputInterface.php£��/ô¥a£��ÆBŒ'¤������,���vendor/symfony/console/Input/InputOption.php ��/ô¥a ��\¢Ü=¤������,���vendor/symfony/console/Input/StringInput.php™��/ô¥a™��{Šœþ¤���������vendor/symfony/console/LICENSE+��/ô¥a+��²‹ g¤������/���vendor/symfony/console/Logger/ConsoleLogger.php- ��/ô¥a- ��ghT›¤������0���vendor/symfony/console/Output/BufferedOutput.php_��/ô¥a_��‹ >P¤������/���vendor/symfony/console/Output/ConsoleOutput.php±��/ô¥a±��nì!f¤������8���vendor/symfony/console/Output/ConsoleOutputInterface.phpà���/ô¥aà���‡†Æʤ������,���vendor/symfony/console/Output/NullOutput.phpÉ��/ô¥aÉ��™0ïf¤������(���vendor/symfony/console/Output/Output.php˜ ��/ô¥a˜ ��0p¤������1���vendor/symfony/console/Output/OutputInterface.php��/ô¥a���ì&¤������.���vendor/symfony/console/Output/StreamOutput.php›��/ô¥a›��.¡îî¤������2���vendor/symfony/console/Question/ChoiceQuestion.phpv
  64. ��/ô¥av
  65. ��‹²WP¤������8���vendor/symfony/console/Question/ConfirmationQuestion.phpè��/ô¥aè��/Ô�¤������,���vendor/symfony/console/Question/Question.phpÎ ��/ô¥aÎ ��lF¤������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��/ô¥a�$��•�¥v¤������ ���vendor/symfony/console/Shell.phpã��/ô¥aã��‰ÁŽå¤������,���vendor/symfony/console/Style/OutputStyle.php\��/ô¥a\��wפ¤������/���vendor/symfony/console/Style/StyleInterface.phpÏ��/ô¥aÏ��&nÅѤ������-���vendor/symfony/console/Style/SymfonyStyle.phpÛ��/ô¥aÛ��§ðcä¤������3���vendor/symfony/console/Tester/ApplicationTester.phpÏ��/ô¥aÏ��sž9i¤������/���vendor/symfony/console/Tester/CommandTester.php¨��/ô¥a¨��<œ•¤������(���vendor/symfony/debug/BufferingLogger.phpt��/ô¥at��=�hܤ���������vendor/symfony/debug/Debug.php+��/ô¥a+��.À=©¤������)���vendor/symfony/debug/DebugClassLoader.php°��/ô¥a°��^æ*ñ¤������%���vendor/symfony/debug/ErrorHandler.phpýG��/ô¥aýG��¿zL¤������9���vendor/symfony/debug/Exception/ClassNotFoundException.php–��/ô¥a–��i‰æô¤������8���vendor/symfony/debug/Exception/ContextErrorException.php˜��/ô¥a˜��-
  66. d2¤������1���vendor/symfony/debug/Exception/DummyException.php��/ô¥a��®+Ãê¤������6���vendor/symfony/debug/Exception/FatalErrorException.php ��/ô¥a ��4ç$¤¤������6���vendor/symfony/debug/Exception/FatalThrowableError.phpW��/ô¥aW��?àèK¤������3���vendor/symfony/debug/Exception/FlattenException.php»��/ô¥a»��+a&¤������7���vendor/symfony/debug/Exception/OutOfMemoryException.php~���/ô¥a~���ë¨oâ¤������=���vendor/symfony/debug/Exception/UndefinedFunctionException.phpš��/ô¥aš���ñJÀ¤������;���vendor/symfony/debug/Exception/UndefinedMethodException.php˜��/ô¥a˜��nöêؤ������)���vendor/symfony/debug/ExceptionHandler.php$3��/ô¥a$3��Eë×£¤������I���vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php5��/ô¥a5��ŠÁ*V¤������E���vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php��/ô¥a��ĹBV¤������M���vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.phpx��/ô¥ax��~ò"¤������K���vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.phpN��/ô¥aN��'€³ˆ¤���������vendor/symfony/debug/LICENSE+��/ô¥a+��²‹ g¤������:���vendor/symfony/filesystem/Exception/ExceptionInterface.phpi���/ô¥ai���$ ÿ›¤������=���vendor/symfony/filesystem/Exception/FileNotFoundException.php¼��/ô¥a¼��pí\¶¤������3���vendor/symfony/filesystem/Exception/IOException.php‡��/ô¥a‡��€ü#Ѥ������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���/ô¥a¦���jÙwM¤������(���vendor/symfony/filesystem/Filesystem.phpM4��/ô¥aM4��ãz_¤������!���vendor/symfony/filesystem/LICENSE+��/ô¥a+��²‹ g¤������)���vendor/symfony/filesystem/LockHandler.phpò��/ô¥aò��~3ŸZ¤������1���vendor/symfony/finder/Adapter/AbstractAdapter.php\ ��/ô¥a\ ��hˆB¤������5���vendor/symfony/finder/Adapter/AbstractFindAdapter.phpƒ��/ô¥aƒ��kM Þ¤������2���vendor/symfony/finder/Adapter/AdapterInterface.php›��/ô¥a›��Mþ¤������0���vendor/symfony/finder/Adapter/BsdFindAdapter.php2��/ô¥a2��ƒ€D)¤������0���vendor/symfony/finder/Adapter/GnuFindAdapter.php��/ô¥a��¦äàO¤������,���vendor/symfony/finder/Adapter/PhpAdapter.phpô��/ô¥aô��Þdè;¤������/���vendor/symfony/finder/Comparator/Comparator.php���/ô¥a���¾üœµ¤������3���vendor/symfony/finder/Comparator/DateComparator.php#��/ô¥a#��°Τ������5���vendor/symfony/finder/Comparator/NumberComparator.php{��/ô¥a{��€ÚùY¤������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���/ô¥a„���½¾sœ¤������;���vendor/symfony/finder/Exception/AdapterFailureException.php¬��/ô¥a¬��wR¤������6���vendor/symfony/finder/Exception/ExceptionInterface.php„���/ô¥a„���Gz-¤������A���vendor/symfony/finder/Exception/OperationNotPermitedException.php)��/ô¥a)��x§e¤������@���vendor/symfony/finder/Exception/ShellCommandFailureException.phpº��/ô¥aº��˜þ˜¤������/���vendor/symfony/finder/Expression/Expression.php��/ô¥a��i¥:Ť������)���vendor/symfony/finder/Expression/Glob.phpf��/ô¥af��DÞcj¤������*���vendor/symfony/finder/Expression/Regex.php��/ô¥a��§;M)¤������3���vendor/symfony/finder/Expression/ValueInterface.phpÍ��/ô¥aÍ��\p4†¤������ ���vendor/symfony/finder/Finder.phpc.��/ô¥ac.��:ˆ5g¤���������vendor/symfony/finder/Glob.phpL��/ô¥aL��jÍ9פ������7���vendor/symfony/finder/Iterator/CustomFilterIterator.php]��/ô¥a]��ÎoÅƤ������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.phpx��/ô¥ax��ôP¤������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.phpî��/ô¥aî��üÍ�q¤������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.phpí��/ô¥aí��nõH¤������4���vendor/symfony/finder/Iterator/FilePathsIterator.php#��/ô¥a#��G?T½¤������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpZ��/ô¥aZ��(&ø¤������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.php5��/ô¥a5��ší¤������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.phpr��/ô¥ar��tu¤������1���vendor/symfony/finder/Iterator/FilterIterator.phpÂ��/ô¥aÂ���㯤������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php*��/ô¥a*��Œž�¤������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpÐ��/ô¥aÐ��‚c¤������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php ��/ô¥a ��O}Cä¤������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.phpe��/ô¥ae��Ÿ’áé¤������3���vendor/symfony/finder/Iterator/SortableIterator.php+��/ô¥a+��õÝË ¤���������vendor/symfony/finder/LICENSE+��/ô¥a+��²‹ g¤������'���vendor/symfony/finder/Shell/Command.php> ��/ô¥a> ��_~u ¤������%���vendor/symfony/finder/Shell/Shell.phpq��/ô¥aq��·ÓŠ0¤������%���vendor/symfony/finder/SplFileInfo.php��/ô¥a��þ�íù¤������'���vendor/symfony/polyfill-ctype/Ctype.phpH ��/ô¥aH ��³�Õݤ������%���vendor/symfony/polyfill-ctype/LICENSE+��/ô¥a+��…»E:¤������+���vendor/symfony/polyfill-ctype/bootstrap.phpú��/ô¥aú��|p:¤������(���vendor/symfony/polyfill-mbstring/LICENSE+��/ô¥a+��øÛ{¤������-���vendor/symfony/polyfill-mbstring/Mbstring.php~G��/ô¥a~G��úì¡T¤������D���vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8Ë��/ô¥aË��Ú�.‚¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php÷T��/ô¥a÷T��ß2ª?¤������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��/ô¥aã��öy_•¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.phpîU��/ô¥aîU��`þ8Q¤������.���vendor/symfony/polyfill-mbstring/bootstrap.php��/ô¥a��þJ¾¤������7���vendor/symfony/process/Exception/ExceptionInterface.phpf���/ô¥af���]ö>T¤������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���/ô¥a¨���ÐÀ+_¤������3���vendor/symfony/process/Exception/LogicException.php”���/ô¥a”��� ³ãñ¤������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��/ô¥ax��¨Ìzy¤������=���vendor/symfony/process/Exception/ProcessTimedOutException.php��/ô¥a��﫤������5���vendor/symfony/process/Exception/RuntimeException.php˜���/ô¥a˜���¢Ø:¤������+���vendor/symfony/process/ExecutableFinder.phpœ��/ô¥aœ��çÁ̤���������vendor/symfony/process/LICENSE+��/ô¥a+��²‹ g¤������.���vendor/symfony/process/PhpExecutableFinder.phpÍ��/ô¥aÍ��í0ã¤������%���vendor/symfony/process/PhpProcess.phpù��/ô¥aù��c¶ßĤ������.���vendor/symfony/process/Pipes/AbstractPipes.php¸��/ô¥a¸��xÓ,§¤������/���vendor/symfony/process/Pipes/PipesInterface.phpD��/ô¥aD��vØ������*���vendor/symfony/process/Pipes/UnixPipes.php7��/ô¥a7��bÜp„¤������-���vendor/symfony/process/Pipes/WindowsPipes.phpi ��/ô¥ai ��Ó
  67.  Ä¤������"���vendor/symfony/process/Process.php R��/ô¥a R��×Ó¥¹¤������)���vendor/symfony/process/ProcessBuilder.phpá
  68. ��/ô¥aá
  69. ��ñ6I•¤������'���vendor/symfony/process/ProcessUtils.phpJ��/ô¥aJ��{ñC¤������ ���bin/composer¨��/ô¥a¨��|¿ùª¤���������LICENSE.��/ô¥a.�� Õ¤������<?php
  70. namespace Composer\Autoload;
  71. use Composer\Config;
  72. use Composer\EventDispatcher\EventDispatcher;
  73. use Composer\Installer\InstallationManager;
  74. use Composer\IO\IOInterface;
  75. use Composer\Package\AliasPackage;
  76. use Composer\Package\PackageInterface;
  77. use Composer\Package\RootPackageInterface;
  78. use Composer\Repository\InstalledRepositoryInterface;
  79. use Composer\Repository\PlatformRepository;
  80. use Composer\Semver\Constraint\Bound;
  81. use Composer\Util\Filesystem;
  82. use Composer\Util\Platform;
  83. use Composer\Script\ScriptEvents;
  84. use Composer\Util\PackageSorter;
  85. use Composer\Json\JsonFile;
  86. class AutoloadGenerator
  87. {
  88. private $eventDispatcher;
  89. private $io;
  90. private $devMode = null;
  91. private $classMapAuthoritative = false;
  92. private $apcu = false;
  93. private $apcuPrefix;
  94. private $runScripts = false;
  95. private $ignorePlatformReqs = false;
  96. public function __construct(EventDispatcher $eventDispatcher, IOInterface $io = null)
  97. {
  98. $this->eventDispatcher = $eventDispatcher;
  99. $this->io = $io;
  100. }
  101. public function setDevMode($devMode = true)
  102. {
  103. $this->devMode = (bool) $devMode;
  104. }
  105. public function setClassMapAuthoritative($classMapAuthoritative)
  106. {
  107. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  108. }
  109. public function setApcu($apcu, $apcuPrefix = null)
  110. {
  111. $this->apcu = (bool) $apcu;
  112. $this->apcuPrefix = $apcuPrefix !== null ? (string) $apcuPrefix : $apcuPrefix;
  113. }
  114. public function setRunScripts($runScripts = true)
  115. {
  116. $this->runScripts = (bool) $runScripts;
  117. }
  118. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  119. {
  120. if (is_array($ignorePlatformReqs)) {
  121. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  122. return PlatformRepository::isPlatformPackage($req);
  123. });
  124. } else {
  125. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  126. }
  127. }
  128. public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, $targetDir, $scanPsrPackages = false, $suffix = '')
  129. {
  130. if ($this->classMapAuthoritative) {
  131. $scanPsrPackages = true;
  132. }
  133. if (null === $this->devMode) {
  134. $this->devMode = false;
  135. $installedJson = new JsonFile($config->get('vendor-dir').'/composer/installed.json');
  136. if ($installedJson->exists()) {
  137. $installedJson = $installedJson->read();
  138. if (isset($installedJson['dev'])) {
  139. $this->devMode = $installedJson['dev'];
  140. }
  141. }
  142. }
  143. if ($this->runScripts) {
  144. if (!isset($_SERVER['COMPOSER_DEV_MODE'])) {
  145. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  146. }
  147. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
  148. 'optimize' => (bool) $scanPsrPackages,
  149. ));
  150. }
  151. $filesystem = new Filesystem();
  152. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  153. $basePath = $filesystem->normalizePath(realpath(realpath(getcwd())));
  154. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  155. $useGlobalIncludePath = (bool) $config->get('use-include-path');
  156. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  157. $targetDir = $vendorPath.'/'.$targetDir;
  158. $filesystem->ensureDirectoryExists($targetDir);
  159. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  160. $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
  161. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  162. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  163. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  164. $namespacesFile = <<<EOF
  165. <?php
  166. // autoload_namespaces.php @generated by Composer
  167. \$vendorDir = $vendorPathCode52;
  168. \$baseDir = $appBaseDirCode;
  169. return array(
  170. EOF;
  171. $psr4File = <<<EOF
  172. <?php
  173. // autoload_psr4.php @generated by Composer
  174. \$vendorDir = $vendorPathCode52;
  175. \$baseDir = $appBaseDirCode;
  176. return array(
  177. EOF;
  178. $devPackageNames = $localRepo->getDevPackageNames();
  179. $packageMap = $this->buildPackageMap($installationManager, $rootPackage, $localRepo->getCanonicalPackages());
  180. if ($this->devMode) {
  181. $filteredDevPackages = false;
  182. } else {
  183. $filteredDevPackages = $devPackageNames ?: true;
  184. }
  185. $autoloads = $this->parseAutoloads($packageMap, $rootPackage, $filteredDevPackages);
  186. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  187. $exportedPaths = array();
  188. foreach ($paths as $path) {
  189. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  190. }
  191. $exportedPrefix = var_export($namespace, true);
  192. $namespacesFile .= " $exportedPrefix => ";
  193. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  194. }
  195. $namespacesFile .= ");\n";
  196. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  197. $exportedPaths = array();
  198. foreach ($paths as $path) {
  199. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  200. }
  201. $exportedPrefix = var_export($namespace, true);
  202. $psr4File .= " $exportedPrefix => ";
  203. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  204. }
  205. $psr4File .= ");\n";
  206. $classmapFile = <<<EOF
  207. <?php
  208. // autoload_classmap.php @generated by Composer
  209. \$vendorDir = $vendorPathCode52;
  210. \$baseDir = $appBaseDirCode;
  211. return array(
  212. EOF;
  213. $targetDirLoader = null;
  214. $mainAutoload = $rootPackage->getAutoload();
  215. if ($rootPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  216. $levels = substr_count($filesystem->normalizePath($rootPackage->getTargetDir()), '/') + 1;
  217. $prefixes = implode(', ', array_map(function ($prefix) {
  218. return var_export($prefix, true);
  219. }, array_keys($mainAutoload['psr-0'])));
  220. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  221. $targetDirLoader = <<<EOF
  222. public static function autoload(\$class)
  223. {
  224. \$dir = $baseDirFromTargetDirCode . '/';
  225. \$prefixes = array($prefixes);
  226. foreach (\$prefixes as \$prefix) {
  227. if (0 !== strpos(\$class, \$prefix)) {
  228. continue;
  229. }
  230. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  231. if (!\$path = stream_resolve_include_path(\$path)) {
  232. return false;
  233. }
  234. require \$path;
  235. return true;
  236. }
  237. }
  238. EOF;
  239. }
  240. $excluded = null;
  241. if (!empty($autoloads['exclude-from-classmap'])) {
  242. $excluded = $autoloads['exclude-from-classmap'];
  243. }
  244. $classMap = array();
  245. $ambiguousClasses = array();
  246. $scannedFiles = array();
  247. foreach ($autoloads['classmap'] as $dir) {
  248. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, null, null, $classMap, $ambiguousClasses, $scannedFiles);
  249. }
  250. if ($scanPsrPackages) {
  251. $namespacesToScan = array();
  252. foreach (array('psr-4', 'psr-0') as $psrType) {
  253. foreach ($autoloads[$psrType] as $namespace => $paths) {
  254. $namespacesToScan[$namespace][] = array('paths' => $paths, 'type' => $psrType);
  255. }
  256. }
  257. krsort($namespacesToScan);
  258. foreach ($namespacesToScan as $namespace => $groups) {
  259. foreach ($groups as $group) {
  260. foreach ($group['paths'] as $dir) {
  261. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  262. if (!is_dir($dir)) {
  263. continue;
  264. }
  265. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespace, $group['type'], $classMap, $ambiguousClasses, $scannedFiles);
  266. }
  267. }
  268. }
  269. }
  270. foreach ($ambiguousClasses as $className => $ambigiousPaths) {
  271. $cleanPath = str_replace(array('$vendorDir . \'', '$baseDir . \'', "',\n"), array($vendorPath, $basePath, ''), $classMap[$className]);
  272. $this->io->writeError(
  273. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  274. ' was found '. (count($ambigiousPaths) + 1) .'x: in "'.$cleanPath.'" and "'. implode('", "', $ambigiousPaths) .'", the first will be used.</warning>'
  275. );
  276. }
  277. $classMap['Composer\\InstalledVersions'] = "\$vendorDir . '/composer/InstalledVersions.php',\n";
  278. ksort($classMap);
  279. foreach ($classMap as $class => $code) {
  280. $classmapFile .= ' '.var_export($class, true).' => '.$code;
  281. }
  282. $classmapFile .= ");\n";
  283. if (!$suffix) {
  284. if (!$config->get('autoloader-suffix') && Filesystem::isReadable($vendorPath.'/autoload.php')) {
  285. $content = file_get_contents($vendorPath.'/autoload.php');
  286. if (preg_match('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  287. $suffix = $match[1];
  288. }
  289. }
  290. if (!$suffix) {
  291. $suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true));
  292. }
  293. }
  294. $filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
  295. $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
  296. $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
  297. $includePathFilePath = $targetDir.'/include_paths.php';
  298. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  299. $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
  300. } elseif (file_exists($includePathFilePath)) {
  301. unlink($includePathFilePath);
  302. }
  303. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  304. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  305. $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
  306. } elseif (file_exists($includeFilesFilePath)) {
  307. unlink($includeFilesFilePath);
  308. }
  309. $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion));
  310. $checkPlatform = $config->get('platform-check') && $this->ignorePlatformReqs !== true;
  311. $platformCheckContent = null;
  312. if ($checkPlatform) {
  313. $platformCheckContent = $this->getPlatformCheck($packageMap, $this->ignorePlatformReqs ?: array(), $config->get('platform-check'), $devPackageNames);
  314. if (null === $platformCheckContent) {
  315. $checkPlatform = false;
  316. }
  317. }
  318. if ($checkPlatform) {
  319. $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);
  320. } elseif (file_exists($targetDir.'/platform_check.php')) {
  321. unlink($targetDir.'/platform_check.php');
  322. }
  323. $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  324. $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform));
  325. $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  326. $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  327. if ($this->runScripts) {
  328. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
  329. 'optimize' => (bool) $scanPsrPackages,
  330. ));
  331. }
  332. return count($classMap);
  333. }
  334. private function addClassMapCode(Filesystem $filesystem, $basePath, $vendorPath, $dir, $excluded, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles)
  335. {
  336. foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
  337. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  338. if (!isset($classMap[$class])) {
  339. $classMap[$class] = $pathCode;
  340. } elseif ($this->io && $classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
  341. $ambiguousClasses[$class][] = $path;
  342. }
  343. }
  344. return $classMap;
  345. }
  346. private function generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, $showAmbiguousWarning, array &$scannedFiles)
  347. {
  348. if ($excluded) {
  349. if (file_exists($dir)) {
  350. $dirMatch = preg_quote(strtr(realpath($dir), '\\', '/'));
  351. foreach ($excluded as $index => $pattern) {
  352. $pattern = preg_replace('{^(([^.+*?\[^\]$(){}=!<>|:\\\\#-]+|\\\\[.+*?\[^\]$(){}=!<>|:#-])*).*}', '$1', $pattern);
  353. if (0 !== strpos($pattern, $dirMatch) && 0 !== strpos($dirMatch, $pattern)) {
  354. unset($excluded[$index]);
  355. }
  356. }
  357. }
  358. $excluded = $excluded ? '{(' . implode('|', $excluded) . ')}' : null;
  359. }
  360. return ClassMapGenerator::createMap($dir, $excluded, $showAmbiguousWarning ? $this->io : null, $namespaceFilter, $autoloadType, $scannedFiles);
  361. }
  362. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $rootPackage, array $packages)
  363. {
  364. $packageMap = array(array($rootPackage, ''));
  365. foreach ($packages as $package) {
  366. if ($package instanceof AliasPackage) {
  367. continue;
  368. }
  369. $this->validatePackage($package);
  370. $packageMap[] = array(
  371. $package,
  372. $installationManager->getInstallPath($package),
  373. );
  374. }
  375. return $packageMap;
  376. }
  377. protected function validatePackage(PackageInterface $package)
  378. {
  379. $autoload = $package->getAutoload();
  380. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  381. $name = $package->getName();
  382. $package->getTargetDir();
  383. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  384. }
  385. if (!empty($autoload['psr-4'])) {
  386. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  387. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  388. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  389. }
  390. }
  391. }
  392. }
  393. public function parseAutoloads(array $packageMap, PackageInterface $rootPackage, $filteredDevPackages = false)
  394. {
  395. $rootPackageMap = array_shift($packageMap);
  396. if (is_array($filteredDevPackages)) {
  397. $packageMap = array_filter($packageMap, function ($item) use ($filteredDevPackages) {
  398. return !in_array($item[0]->getName(), $filteredDevPackages, true);
  399. });
  400. } elseif ($filteredDevPackages) {
  401. $packageMap = $this->filterPackageMap($packageMap, $rootPackage);
  402. }
  403. $sortedPackageMap = $this->sortPackageMap($packageMap);
  404. $sortedPackageMap[] = $rootPackageMap;
  405. array_unshift($packageMap, $rootPackageMap);
  406. $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $rootPackage);
  407. $psr4 = $this->parseAutoloadsType($packageMap, 'psr-4', $rootPackage);
  408. $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $rootPackage);
  409. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $rootPackage);
  410. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $rootPackage);
  411. krsort($psr0);
  412. krsort($psr4);
  413. return array(
  414. 'psr-0' => $psr0,
  415. 'psr-4' => $psr4,
  416. 'classmap' => $classmap,
  417. 'files' => $files,
  418. 'exclude-from-classmap' => $exclude,
  419. );
  420. }
  421. public function createLoader(array $autoloads, $vendorDir = null)
  422. {
  423. $loader = new ClassLoader($vendorDir);
  424. if (isset($autoloads['psr-0'])) {
  425. foreach ($autoloads['psr-0'] as $namespace => $path) {
  426. $loader->add($namespace, $path);
  427. }
  428. }
  429. if (isset($autoloads['psr-4'])) {
  430. foreach ($autoloads['psr-4'] as $namespace => $path) {
  431. $loader->addPsr4($namespace, $path);
  432. }
  433. }
  434. if (isset($autoloads['classmap'])) {
  435. $excluded = null;
  436. if (!empty($autoloads['exclude-from-classmap'])) {
  437. $excluded = $autoloads['exclude-from-classmap'];
  438. }
  439. $scannedFiles = array();
  440. foreach ($autoloads['classmap'] as $dir) {
  441. try {
  442. $loader->addClassMap($this->generateClassMap($dir, $excluded, null, null, false, $scannedFiles));
  443. } catch (\RuntimeException $e) {
  444. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  445. }
  446. }
  447. }
  448. return $loader;
  449. }
  450. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  451. {
  452. $includePaths = array();
  453. foreach ($packageMap as $item) {
  454. list($package, $installPath) = $item;
  455. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  456. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  457. }
  458. foreach ($package->getIncludePaths() as $includePath) {
  459. $includePath = trim($includePath, '/');
  460. $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
  461. }
  462. }
  463. if (!$includePaths) {
  464. return null;
  465. }
  466. $includePathsCode = '';
  467. foreach ($includePaths as $path) {
  468. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  469. }
  470. return <<<EOF
  471. <?php
  472. // include_paths.php @generated by Composer
  473. \$vendorDir = $vendorPathCode;
  474. \$baseDir = $appBaseDirCode;
  475. return array(
  476. $includePathsCode);
  477. EOF;
  478. }
  479. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  480. {
  481. $filesCode = '';
  482. foreach ($files as $fileIdentifier => $functionFile) {
  483. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
  484. . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
  485. }
  486. if (!$filesCode) {
  487. return null;
  488. }
  489. return <<<EOF
  490. <?php
  491. // autoload_files.php @generated by Composer
  492. \$vendorDir = $vendorPathCode;
  493. \$baseDir = $appBaseDirCode;
  494. return array(
  495. $filesCode);
  496. EOF;
  497. }
  498. protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
  499. {
  500. if (!$filesystem->isAbsolutePath($path)) {
  501. $path = $basePath . '/' . $path;
  502. }
  503. $path = $filesystem->normalizePath($path);
  504. $baseDir = '';
  505. if (strpos($path.'/', $vendorPath.'/') === 0) {
  506. $path = substr($path, strlen($vendorPath));
  507. $baseDir = '$vendorDir';
  508. if ($path !== false) {
  509. $baseDir .= " . ";
  510. }
  511. } else {
  512. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  513. if (!$filesystem->isAbsolutePath($path)) {
  514. $baseDir = '$baseDir . ';
  515. $path = '/' . $path;
  516. }
  517. }
  518. if (strpos($path, '.phar') !== false) {
  519. $baseDir = "'phar://' . " . $baseDir;
  520. }
  521. return $baseDir . var_export($path, true);
  522. }
  523. protected function getPlatformCheck(array $packageMap, array $ignorePlatformReqs, $checkPlatform, array $devPackageNames)
  524. {
  525. $lowestPhpVersion = Bound::zero();
  526. $requiredExtensions = array();
  527. $extensionProviders = array();
  528. foreach ($packageMap as $item) {
  529. $package = $item[0];
  530. foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
  531. if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  532. $extensionProviders[$match[1]][] = $link->getConstraint();
  533. }
  534. }
  535. }
  536. foreach ($packageMap as $item) {
  537. $package = $item[0];
  538. if (in_array($package->getName(), $devPackageNames, true)) {
  539. continue;
  540. }
  541. foreach ($package->getRequires() as $link) {
  542. if (in_array($link->getTarget(), $ignorePlatformReqs, true)) {
  543. continue;
  544. }
  545. if ('php' === $link->getTarget()) {
  546. $constraint = $link->getConstraint();
  547. if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
  548. $lowestPhpVersion = $constraint->getLowerBound();
  549. }
  550. }
  551. if ($checkPlatform === true && preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  552. if (isset($extensionProviders[$match[1]])) {
  553. foreach ($extensionProviders[$match[1]] as $provided) {
  554. if ($provided->matches($link->getConstraint())) {
  555. continue 2;
  556. }
  557. }
  558. }
  559. if ($match[1] === 'zend-opcache') {
  560. $match[1] = 'zend opcache';
  561. }
  562. $extension = var_export($match[1], true);
  563. if ($match[1] === 'pcntl' || $match[1] === 'readline') {
  564. $requiredExtensions[$extension] = "PHP_SAPI !== 'cli' || extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  565. } else {
  566. $requiredExtensions[$extension] = "extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  567. }
  568. }
  569. }
  570. }
  571. ksort($requiredExtensions);
  572. $formatToPhpVersionId = function (Bound $bound) {
  573. if ($bound->isZero()) {
  574. return 0;
  575. }
  576. if ($bound->isPositiveInfinity()) {
  577. return 99999;
  578. }
  579. $version = str_replace('-', '.', $bound->getVersion());
  580. $chunks = array_map('intval', explode('.', $version));
  581. return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
  582. };
  583. $formatToHumanReadable = function (Bound $bound) {
  584. if ($bound->isZero()) {
  585. return 0;
  586. }
  587. if ($bound->isPositiveInfinity()) {
  588. return 99999;
  589. }
  590. $version = str_replace('-', '.', $bound->getVersion());
  591. $chunks = explode('.', $version);
  592. $chunks = array_slice($chunks, 0, 3);
  593. return implode('.', $chunks);
  594. };
  595. $requiredPhp = '';
  596. $requiredPhpError = '';
  597. if (!$lowestPhpVersion->isZero()) {
  598. $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
  599. $requiredPhp = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
  600. $requiredPhpError = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
  601. }
  602. if ($requiredPhp) {
  603. $requiredPhp = <<<PHP_CHECK
  604. if (!($requiredPhp)) {
  605. \$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
  606. }
  607. PHP_CHECK;
  608. }
  609. $requiredExtensions = implode('', $requiredExtensions);
  610. if ('' !== $requiredExtensions) {
  611. $requiredExtensions = <<<EXT_CHECKS
  612. \$missingExtensions = array();
  613. $requiredExtensions
  614. if (\$missingExtensions) {
  615. \$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', \$missingExtensions) . '.';
  616. }
  617. EXT_CHECKS;
  618. }
  619. if (!$requiredPhp && !$requiredExtensions) {
  620. return null;
  621. }
  622. return <<<PLATFORM_CHECK
  623. <?php
  624. // platform_check.php @generated by Composer
  625. \$issues = array();
  626. ${requiredPhp}${requiredExtensions}
  627. if (\$issues) {
  628. if (!headers_sent()) {
  629. header('HTTP/1.1 500 Internal Server Error');
  630. }
  631. if (!ini_get('display_errors')) {
  632. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  633. fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, \$issues) . PHP_EOL.PHP_EOL);
  634. } elseif (!headers_sent()) {
  635. 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;
  636. }
  637. }
  638. trigger_error(
  639. 'Composer detected issues in your platform: ' . implode(' ', \$issues),
  640. E_USER_ERROR
  641. );
  642. }
  643. PLATFORM_CHECK;
  644. }
  645. protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
  646. {
  647. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  648. if ("'" === $lastChar || '"' === $lastChar) {
  649. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  650. } else {
  651. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  652. }
  653. return <<<AUTOLOAD
  654. <?php
  655. // autoload.php @generated by Composer
  656. require_once $vendorPathToTargetDirCode;
  657. return ComposerAutoloaderInit$suffix::getLoader();
  658. AUTOLOAD;
  659. }
  660. protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform)
  661. {
  662. $file = <<<HEADER
  663. <?php
  664. // autoload_real.php @generated by Composer
  665. class ComposerAutoloaderInit$suffix
  666. {
  667. private static \$loader;
  668. public static function loadClassLoader(\$class)
  669. {
  670. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  671. require __DIR__ . '/ClassLoader.php';
  672. }
  673. }
  674. /**
  675. * @return \Composer\Autoload\ClassLoader
  676. */
  677. public static function getLoader()
  678. {
  679. if (null !== self::\$loader) {
  680. return self::\$loader;
  681. }
  682. HEADER;
  683. if ($checkPlatform) {
  684. $file .= <<<'PLATFORM_CHECK'
  685. require __DIR__ . '/platform_check.php';
  686. PLATFORM_CHECK;
  687. }
  688. $file .= <<<CLASSLOADER_INIT
  689. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  690. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(\\dirname(__FILE__)));
  691. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  692. CLASSLOADER_INIT;
  693. if ($useIncludePath) {
  694. $file .= <<<'INCLUDE_PATH'
  695. $includePaths = require __DIR__ . '/include_paths.php';
  696. $includePaths[] = get_include_path();
  697. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  698. INCLUDE_PATH;
  699. }
  700. $file .= <<<STATIC_INIT
  701. \$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  702. if (\$useStaticLoader) {
  703. require __DIR__ . '/autoload_static.php';
  704. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  705. } else {
  706. STATIC_INIT;
  707. if (!$this->classMapAuthoritative) {
  708. $file .= <<<'PSR04'
  709. $map = require __DIR__ . '/autoload_namespaces.php';
  710. foreach ($map as $namespace => $path) {
  711. $loader->set($namespace, $path);
  712. }
  713. $map = require __DIR__ . '/autoload_psr4.php';
  714. foreach ($map as $namespace => $path) {
  715. $loader->setPsr4($namespace, $path);
  716. }
  717. PSR04;
  718. }
  719. if ($useClassMap) {
  720. $file .= <<<'CLASSMAP'
  721. $classMap = require __DIR__ . '/autoload_classmap.php';
  722. if ($classMap) {
  723. $loader->addClassMap($classMap);
  724. }
  725. CLASSMAP;
  726. }
  727. $file .= " }\n\n";
  728. if ($this->classMapAuthoritative) {
  729. $file .= <<<'CLASSMAPAUTHORITATIVE'
  730. $loader->setClassMapAuthoritative(true);
  731. CLASSMAPAUTHORITATIVE;
  732. }
  733. if ($this->apcu) {
  734. $apcuPrefix = var_export(($this->apcuPrefix !== null ? $this->apcuPrefix : substr(base64_encode(md5(uniqid('', true), true)), 0, -3)), true);
  735. $file .= <<<APCU
  736. \$loader->setApcuPrefix($apcuPrefix);
  737. APCU;
  738. }
  739. if ($useGlobalIncludePath) {
  740. $file .= <<<'INCLUDEPATH'
  741. $loader->setUseIncludePath(true);
  742. INCLUDEPATH;
  743. }
  744. if ($targetDirLoader) {
  745. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  746. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  747. REGISTER_TARGET_DIR_AUTOLOAD;
  748. }
  749. $file .= <<<REGISTER_LOADER
  750. \$loader->register($prependAutoloader);
  751. REGISTER_LOADER;
  752. if ($useIncludeFiles) {
  753. $file .= <<<INCLUDE_FILES
  754. if (\$useStaticLoader) {
  755. \$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
  756. } else {
  757. \$includeFiles = require __DIR__ . '/autoload_files.php';
  758. }
  759. foreach (\$includeFiles as \$fileIdentifier => \$file) {
  760. composerRequire$suffix(\$fileIdentifier, \$file);
  761. }
  762. INCLUDE_FILES;
  763. }
  764. $file .= <<<METHOD_FOOTER
  765. return \$loader;
  766. }
  767. METHOD_FOOTER;
  768. $file .= $targetDirLoader;
  769. if ($useIncludeFiles) {
  770. return $file . <<<FOOTER
  771. }
  772. function composerRequire$suffix(\$fileIdentifier, \$file)
  773. {
  774. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  775. require \$file;
  776. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  777. }
  778. }
  779. FOOTER;
  780. }
  781. return $file . <<<FOOTER
  782. }
  783. FOOTER;
  784. }
  785. protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion)
  786. {
  787. $staticPhpVersion = 50600;
  788. $file = <<<HEADER
  789. <?php
  790. // autoload_static.php @generated by Composer
  791. namespace Composer\Autoload;
  792. class ComposerStaticInit$suffix
  793. {
  794. HEADER;
  795. $loader = new ClassLoader();
  796. $map = require $targetDir . '/autoload_namespaces.php';
  797. foreach ($map as $namespace => $path) {
  798. $loader->set($namespace, $path);
  799. }
  800. $map = require $targetDir . '/autoload_psr4.php';
  801. foreach ($map as $namespace => $path) {
  802. $loader->setPsr4($namespace, $path);
  803. }
  804. $classMap = require $targetDir . '/autoload_classmap.php';
  805. if ($classMap) {
  806. $loader->addClassMap($classMap);
  807. }
  808. $filesystem = new Filesystem();
  809. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  810. $vendorPharPathCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  811. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  812. $appBaseDirPharCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  813. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  814. $absoluteVendorPharPathCode = ' => ' . substr(var_export(rtrim('phar://' . $vendorDir, '\\/') . '/', true), 0, -1);
  815. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  816. $absoluteAppBaseDirPharCode = ' => ' . substr(var_export(rtrim('phar://' . $baseDir, '\\/') . '/', true), 0, -1);
  817. $initializer = '';
  818. $prefix = "\0Composer\Autoload\ClassLoader\0";
  819. $prefixLen = strlen($prefix);
  820. if (file_exists($targetDir . '/autoload_files.php')) {
  821. $maps = array('files' => require $targetDir . '/autoload_files.php');
  822. } else {
  823. $maps = array();
  824. }
  825. foreach ((array) $loader as $prop => $value) {
  826. if ($value && 0 === strpos($prop, $prefix)) {
  827. $maps[substr($prop, $prefixLen)] = $value;
  828. }
  829. }
  830. foreach ($maps as $prop => $value) {
  831. if (count($value) > 32767) {
  832. $staticPhpVersion = 70000;
  833. }
  834. $value = strtr(
  835. var_export($value, true),
  836. array(
  837. $absoluteVendorPathCode => $vendorPathCode,
  838. $absoluteVendorPharPathCode => $vendorPharPathCode,
  839. $absoluteAppBaseDirCode => $appBaseDirCode,
  840. $absoluteAppBaseDirPharCode => $appBaseDirPharCode,
  841. )
  842. );
  843. $value = ltrim(preg_replace('/^ */m', ' $0$0', $value));
  844. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  845. if ('files' !== $prop) {
  846. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  847. }
  848. }
  849. return $file . <<<INITIALIZER
  850. public static function getInitializer(ClassLoader \$loader)
  851. {
  852. return \Closure::bind(function () use (\$loader) {
  853. $initializer
  854. }, null, ClassLoader::class);
  855. }
  856. }
  857. INITIALIZER;
  858. }
  859. protected function parseAutoloadsType(array $packageMap, $type, RootPackageInterface $rootPackage)
  860. {
  861. $autoloads = array();
  862. foreach ($packageMap as $item) {
  863. list($package, $installPath) = $item;
  864. $autoload = $package->getAutoload();
  865. if ($this->devMode && $package === $rootPackage) {
  866. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  867. }
  868. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  869. continue;
  870. }
  871. if (null !== $package->getTargetDir() && $package !== $rootPackage) {
  872. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  873. }
  874. foreach ($autoload[$type] as $namespace => $paths) {
  875. foreach ((array) $paths as $path) {
  876. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !Filesystem::isReadable($installPath.'/'.$path)) {
  877. if ($package === $rootPackage) {
  878. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(array('/', '\\'), '<dirsep>', $package->getTargetDir())));
  879. $path = ltrim(preg_replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  880. } else {
  881. $path = $package->getTargetDir() . '/' . $path;
  882. }
  883. }
  884. if ($type === 'exclude-from-classmap') {
  885. $path = preg_replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  886. $path = strtr($path, array('\\*\\*' => '.+?', '\\*' => '[^/]+?'));
  887. $updir = null;
  888. $path = preg_replace_callback(
  889. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  890. function ($matches) use (&$updir) {
  891. if (isset($matches[1])) {
  892. $updir = str_replace('\\.', '.', $matches[1]);
  893. }
  894. return '';
  895. },
  896. $path
  897. );
  898. if (empty($installPath)) {
  899. $installPath = strtr(getcwd(), '\\', '/');
  900. }
  901. $resolvedPath = realpath($installPath . '/' . $updir);
  902. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)';
  903. continue;
  904. }
  905. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  906. if ($type === 'files') {
  907. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  908. continue;
  909. }
  910. if ($type === 'classmap') {
  911. $autoloads[] = $relativePath;
  912. continue;
  913. }
  914. $autoloads[$namespace][] = $relativePath;
  915. }
  916. }
  917. }
  918. return $autoloads;
  919. }
  920. protected function getFileIdentifier(PackageInterface $package, $path)
  921. {
  922. return md5($package->getName() . ':' . $path);
  923. }
  924. protected function filterPackageMap(array $packageMap, RootPackageInterface $rootPackage)
  925. {
  926. $packages = array();
  927. $include = array();
  928. $replacedBy = array();
  929. foreach ($packageMap as $item) {
  930. $package = $item[0];
  931. $name = $package->getName();
  932. $packages[$name] = $package;
  933. foreach ($package->getReplaces() as $replace) {
  934. $replacedBy[$replace->getTarget()] = $name;
  935. }
  936. }
  937. $add = function (PackageInterface $package) use (&$add, $packages, &$include, $replacedBy) {
  938. foreach ($package->getRequires() as $link) {
  939. $target = $link->getTarget();
  940. if (isset($replacedBy[$target])) {
  941. $target = $replacedBy[$target];
  942. }
  943. if (!isset($include[$target])) {
  944. $include[$target] = true;
  945. if (isset($packages[$target])) {
  946. $add($packages[$target]);
  947. }
  948. }
  949. }
  950. };
  951. $add($rootPackage);
  952. return array_filter(
  953. $packageMap,
  954. function ($item) use ($include) {
  955. $package = $item[0];
  956. foreach ($package->getNames() as $name) {
  957. if (isset($include[$name])) {
  958. return true;
  959. }
  960. }
  961. return false;
  962. }
  963. );
  964. }
  965. protected function sortPackageMap(array $packageMap)
  966. {
  967. $packages = array();
  968. $paths = array();
  969. foreach ($packageMap as $item) {
  970. list($package, $path) = $item;
  971. $name = $package->getName();
  972. $packages[$name] = $package;
  973. $paths[$name] = $path;
  974. }
  975. $sortedPackages = PackageSorter::sortPackages($packages);
  976. $sortedPackageMap = array();
  977. foreach ($sortedPackages as $package) {
  978. $name = $package->getName();
  979. $sortedPackageMap[] = array($packages[$name], $paths[$name]);
  980. }
  981. return $sortedPackageMap;
  982. }
  983. }
  984. <?php
  985. namespace Composer\Autoload;
  986. use Symfony\Component\Finder\Finder;
  987. use Composer\IO\IOInterface;
  988. use Composer\Util\Filesystem;
  989. class ClassMapGenerator
  990. {
  991. public static function dump($dirs, $file)
  992. {
  993. $maps = array();
  994. foreach ($dirs as $dir) {
  995. $maps = array_merge($maps, static::createMap($dir));
  996. }
  997. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  998. }
  999. public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array())
  1000. {
  1001. $basePath = $path;
  1002. if (is_string($path)) {
  1003. if (is_file($path)) {
  1004. $path = array(new \SplFileInfo($path));
  1005. } elseif (is_dir($path) || strpos($path, '*') !== false) {
  1006. $path = Finder::create()->files()->followLinks()->name('/\.(php|inc|hh)$/')->in($path);
  1007. } else {
  1008. throw new \RuntimeException(
  1009. 'Could not scan for classes inside "'.$path.
  1010. '" which does not appear to be a file nor a folder'
  1011. );
  1012. }
  1013. } elseif (null !== $autoloadType) {
  1014. throw new \RuntimeException('Path must be a string when specifying an autoload type');
  1015. }
  1016. $map = array();
  1017. $filesystem = new Filesystem();
  1018. $cwd = realpath(getcwd());
  1019. foreach ($path as $file) {
  1020. $filePath = $file->getPathname();
  1021. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
  1022. continue;
  1023. }
  1024. if (!$filesystem->isAbsolutePath($filePath)) {
  1025. $filePath = $cwd . '/' . $filePath;
  1026. $filePath = $filesystem->normalizePath($filePath);
  1027. } else {
  1028. $filePath = preg_replace('{[\\\\/]{2,}}', '/', $filePath);
  1029. }
  1030. $realPath = realpath($filePath);
  1031. if (isset($scannedFiles[$realPath])) {
  1032. continue;
  1033. }
  1034. if ($excluded && preg_match($excluded, strtr($realPath, '\\', '/'))) {
  1035. continue;
  1036. }
  1037. if ($excluded && preg_match($excluded, strtr($filePath, '\\', '/'))) {
  1038. continue;
  1039. }
  1040. $classes = self::findClasses($filePath);
  1041. if (null !== $autoloadType) {
  1042. $classes = self::filterByNamespace($classes, $filePath, $namespace, $autoloadType, $basePath, $io);
  1043. if ($classes) {
  1044. $scannedFiles[$realPath] = true;
  1045. }
  1046. } else {
  1047. $scannedFiles[$realPath] = true;
  1048. }
  1049. foreach ($classes as $class) {
  1050. if (null === $autoloadType && null !== $namespace && '' !== $namespace && 0 !== strpos($class, $namespace)) {
  1051. continue;
  1052. }
  1053. if (!isset($map[$class])) {
  1054. $map[$class] = $filePath;
  1055. } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
  1056. $io->writeError(
  1057. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1058. ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
  1059. );
  1060. }
  1061. }
  1062. }
  1063. return $map;
  1064. }
  1065. private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io)
  1066. {
  1067. $validClasses = array();
  1068. $rejectedClasses = array();
  1069. $realSubPath = substr($filePath, strlen($basePath) + 1);
  1070. $realSubPath = substr($realSubPath, 0, strrpos($realSubPath, '.'));
  1071. foreach ($classes as $class) {
  1072. if ('' !== $baseNamespace && 0 !== strpos($class, $baseNamespace)) {
  1073. continue;
  1074. }
  1075. if ('psr-0' === $namespaceType) {
  1076. $namespaceLength = strrpos($class, '\\');
  1077. if (false !== $namespaceLength) {
  1078. $namespace = substr($class, 0, $namespaceLength + 1);
  1079. $className = substr($class, $namespaceLength + 1);
  1080. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
  1081. . str_replace('_', DIRECTORY_SEPARATOR, $className);
  1082. } else {
  1083. $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
  1084. }
  1085. } elseif ('psr-4' === $namespaceType) {
  1086. $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
  1087. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);
  1088. } else {
  1089. throw new \RuntimeException("namespaceType must be psr-0 or psr-4, $namespaceType given");
  1090. }
  1091. if ($subPath === $realSubPath) {
  1092. $validClasses[] = $class;
  1093. } else {
  1094. $rejectedClasses[] = $class;
  1095. }
  1096. }
  1097. if (empty($validClasses)) {
  1098. foreach ($rejectedClasses as $class) {
  1099. if ($io) {
  1100. $io->writeError("<warning>Class $class located in ".preg_replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
  1101. }
  1102. }
  1103. return array();
  1104. }
  1105. return $validClasses;
  1106. }
  1107. private static function findClasses($path)
  1108. {
  1109. $extraTypes = self::getExtraTypes();
  1110. $contents = @php_strip_whitespace($path);
  1111. if (!$contents) {
  1112. if (!file_exists($path)) {
  1113. $message = 'File at "%s" does not exist, check your classmap definitions';
  1114. } elseif (!Filesystem::isReadable($path)) {
  1115. $message = 'File at "%s" is not readable, check its permissions';
  1116. } elseif ('' === trim(file_get_contents($path))) {
  1117. return array();
  1118. } else {
  1119. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  1120. }
  1121. $error = error_get_last();
  1122. if (isset($error['message'])) {
  1123. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  1124. }
  1125. throw new \RuntimeException(sprintf($message, $path));
  1126. }
  1127. preg_match_all('{\b(?:class|interface'.$extraTypes.')\s}i', $contents, $matches);
  1128. if (!$matches) {
  1129. return array();
  1130. }
  1131. $p = new PhpFileCleaner($contents, count($matches[0]));
  1132. $contents = $p->clean();
  1133. unset($p);
  1134. preg_match_all('{
  1135. (?:
  1136. \b(?<![\$:>])(?P<type>class|interface'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  1137. | \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*+ [\{;]
  1138. )
  1139. }ix', $contents, $matches);
  1140. $classes = array();
  1141. $namespace = '';
  1142. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  1143. if (!empty($matches['ns'][$i])) {
  1144. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
  1145. } else {
  1146. $name = $matches['name'][$i];
  1147. if ($name === 'extends' || $name === 'implements') {
  1148. continue;
  1149. }
  1150. if ($name[0] === ':') {
  1151. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  1152. } elseif ($matches['type'][$i] === 'enum') {
  1153. $name = rtrim($name, ':');
  1154. }
  1155. $classes[] = ltrim($namespace . $name, '\\');
  1156. }
  1157. }
  1158. return $classes;
  1159. }
  1160. private static function getExtraTypes()
  1161. {
  1162. static $extraTypes = null;
  1163. if (null === $extraTypes) {
  1164. $extraTypes = PHP_VERSION_ID < 50400 ? '' : '|trait';
  1165. if (PHP_VERSION_ID >= 80100 || (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>='))) {
  1166. $extraTypes .= '|enum';
  1167. }
  1168. PhpFileCleaner::setTypeConfig(array_merge(array('class', 'interface'), array_filter(explode('|', $extraTypes))));
  1169. }
  1170. return $extraTypes;
  1171. }
  1172. }
  1173. <?php
  1174. namespace Composer\Autoload;
  1175. class PhpFileCleaner
  1176. {
  1177. private static $typeConfig;
  1178. private static $restPattern;
  1179. private $contents;
  1180. private $len;
  1181. private $maxMatches;
  1182. private $index = 0;
  1183. public static function setTypeConfig($types)
  1184. {
  1185. foreach ($types as $type) {
  1186. self::$typeConfig[$type[0]] = array(
  1187. 'name' => $type,
  1188. 'length' => \strlen($type),
  1189. 'pattern' => '{.\b(?<![\$:>])'.$type.'\s++[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+}Ais',
  1190. );
  1191. }
  1192. self::$restPattern = '{[^?"\'</'.implode('', array_keys(self::$typeConfig)).']+}A';
  1193. }
  1194. public function __construct($contents, $maxMatches)
  1195. {
  1196. $this->contents = $contents;
  1197. $this->len = \strlen($this->contents);
  1198. $this->maxMatches = $maxMatches;
  1199. }
  1200. public function clean()
  1201. {
  1202. $clean = '';
  1203. while ($this->index < $this->len) {
  1204. $this->skipToPhp();
  1205. $clean .= '<?';
  1206. while ($this->index < $this->len) {
  1207. $char = $this->contents[$this->index];
  1208. if ($char === '?' && $this->peek('>')) {
  1209. $clean .= '?>';
  1210. $this->index += 2;
  1211. continue 2;
  1212. }
  1213. if ($char === '"') {
  1214. $this->skipString('"');
  1215. $clean .= 'null';
  1216. continue;
  1217. }
  1218. if ($char === "'") {
  1219. $this->skipString("'");
  1220. $clean .= 'null';
  1221. continue;
  1222. }
  1223. if ($char === "<" && $this->peek('<') && $this->match('{<<<[ \t]*+([\'"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*+)\\1(?:\r\n|\n|\r)}A', $match)) {
  1224. $this->index += \strlen($match[0]);
  1225. $this->skipHeredoc($match[2]);
  1226. $clean .= 'null';
  1227. continue;
  1228. }
  1229. if ($char === '/') {
  1230. if ($this->peek('/')) {
  1231. $this->skipToNewline();
  1232. continue;
  1233. }
  1234. if ($this->peek('*')) {
  1235. $this->skipComment();
  1236. }
  1237. }
  1238. if ($this->maxMatches === 1 && isset(self::$typeConfig[$char])) {
  1239. $type = self::$typeConfig[$char];
  1240. if (
  1241. \substr($this->contents, $this->index, $type['length']) === $type['name']
  1242. && \preg_match($type['pattern'], $this->contents, $match, 0, $this->index - 1)
  1243. ) {
  1244. $clean .= $match[0];
  1245. return $clean;
  1246. }
  1247. }
  1248. $this->index += 1;
  1249. if ($this->match(self::$restPattern, $match)) {
  1250. $clean .= $char . $match[0];
  1251. $this->index += \strlen($match[0]);
  1252. } else {
  1253. $clean .= $char;
  1254. }
  1255. }
  1256. }
  1257. return $clean;
  1258. }
  1259. private function skipToPhp()
  1260. {
  1261. while ($this->index < $this->len) {
  1262. if ($this->contents[$this->index] === '<' && $this->peek('?')) {
  1263. $this->index += 2;
  1264. break;
  1265. }
  1266. $this->index += 1;
  1267. }
  1268. }
  1269. private function skipString($delimiter)
  1270. {
  1271. $this->index += 1;
  1272. while ($this->index < $this->len) {
  1273. if ($this->contents[$this->index] === '\\' && ($this->peek('\\') || $this->peek($delimiter))) {
  1274. $this->index += 2;
  1275. continue;
  1276. }
  1277. if ($this->contents[$this->index] === $delimiter) {
  1278. $this->index += 1;
  1279. break;
  1280. }
  1281. $this->index += 1;
  1282. }
  1283. }
  1284. private function skipComment()
  1285. {
  1286. $this->index += 2;
  1287. while ($this->index < $this->len) {
  1288. if ($this->contents[$this->index] === '*' && $this->peek('/')) {
  1289. $this->index += 2;
  1290. break;
  1291. }
  1292. $this->index += 1;
  1293. }
  1294. }
  1295. private function skipToNewline()
  1296. {
  1297. while ($this->index < $this->len) {
  1298. if ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n") {
  1299. return;
  1300. }
  1301. $this->index += 1;
  1302. }
  1303. }
  1304. private function skipHeredoc($delimiter)
  1305. {
  1306. $firstDelimiterChar = $delimiter[0];
  1307. $delimiterLength = \strlen($delimiter);
  1308. $delimiterPattern = '{'.preg_quote($delimiter).'(?![a-zA-Z0-9_\x80-\xff])}A';
  1309. while ($this->index < $this->len) {
  1310. switch ($this->contents[$this->index]) {
  1311. case "\t":
  1312. case " ":
  1313. $this->index += 1;
  1314. continue 2;
  1315. case $firstDelimiterChar:
  1316. if (
  1317. \substr($this->contents, $this->index, $delimiterLength) === $delimiter
  1318. && $this->match($delimiterPattern)
  1319. ) {
  1320. $this->index += $delimiterLength;
  1321. return;
  1322. }
  1323. break;
  1324. }
  1325. while ($this->index < $this->len) {
  1326. $this->skipToNewline();
  1327. while ($this->index < $this->len && ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n")) {
  1328. $this->index += 1;
  1329. }
  1330. break;
  1331. }
  1332. }
  1333. }
  1334. private function peek($char)
  1335. {
  1336. return $this->index + 1 < $this->len && $this->contents[$this->index + 1] === $char;
  1337. }
  1338. private function match($regex, array &$match = null)
  1339. {
  1340. if (\preg_match($regex, $this->contents, $match, 0, $this->index)) {
  1341. return true;
  1342. }
  1343. return false;
  1344. }
  1345. }
  1346. <?php
  1347. namespace Composer;
  1348. use Composer\IO\IOInterface;
  1349. use Composer\Util\Filesystem;
  1350. use Composer\Util\Silencer;
  1351. use Symfony\Component\Finder\Finder;
  1352. class Cache
  1353. {
  1354. private static $cacheCollected = null;
  1355. private $io;
  1356. private $root;
  1357. private $enabled = null;
  1358. private $allowlist;
  1359. private $filesystem;
  1360. private $readOnly;
  1361. public function __construct(IOInterface $io, $cacheDir, $allowlist = 'a-z0-9.', Filesystem $filesystem = null, $readOnly = false)
  1362. {
  1363. $this->io = $io;
  1364. $this->root = rtrim($cacheDir, '/\\') . '/';
  1365. $this->allowlist = $allowlist;
  1366. $this->filesystem = $filesystem ?: new Filesystem();
  1367. $this->readOnly = (bool) $readOnly;
  1368. if (!self::isUsable($cacheDir)) {
  1369. $this->enabled = false;
  1370. }
  1371. }
  1372. public function setReadOnly($readOnly)
  1373. {
  1374. $this->readOnly = (bool) $readOnly;
  1375. }
  1376. public function isReadOnly()
  1377. {
  1378. return $this->readOnly;
  1379. }
  1380. public static function isUsable($path)
  1381. {
  1382. return !preg_match('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
  1383. }
  1384. public function isEnabled()
  1385. {
  1386. if ($this->enabled === null) {
  1387. $this->enabled = true;
  1388. if (
  1389. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  1390. || !is_writable($this->root)
  1391. ) {
  1392. $this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache</warning>');
  1393. $this->enabled = false;
  1394. }
  1395. }
  1396. return $this->enabled;
  1397. }
  1398. public function getRoot()
  1399. {
  1400. return $this->root;
  1401. }
  1402. public function read($file)
  1403. {
  1404. if ($this->isEnabled()) {
  1405. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1406. if (file_exists($this->root . $file)) {
  1407. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1408. return file_get_contents($this->root . $file);
  1409. }
  1410. }
  1411. return false;
  1412. }
  1413. public function write($file, $contents)
  1414. {
  1415. if ($this->isEnabled() && !$this->readOnly) {
  1416. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1417. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  1418. $tempFileName = $this->root . $file . uniqid('.', true) . '.tmp';
  1419. try {
  1420. return file_put_contents($tempFileName, $contents) !== false && rename($tempFileName, $this->root . $file);
  1421. } catch (\ErrorException $e) {
  1422. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  1423. if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  1424. unlink($tempFileName);
  1425. $message = sprintf(
  1426. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
  1427. $tempFileName,
  1428. $m[1],
  1429. $m[2],
  1430. @disk_free_space(dirname($tempFileName))
  1431. );
  1432. $this->io->writeError($message);
  1433. return false;
  1434. }
  1435. throw $e;
  1436. }
  1437. }
  1438. return false;
  1439. }
  1440. public function copyFrom($file, $source)
  1441. {
  1442. if ($this->isEnabled() && !$this->readOnly) {
  1443. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1444. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1445. if (!file_exists($source)) {
  1446. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1447. } elseif ($this->io->isDebug()) {
  1448. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1449. }
  1450. return copy($source, $this->root . $file);
  1451. }
  1452. return false;
  1453. }
  1454. public function copyTo($file, $target)
  1455. {
  1456. if ($this->isEnabled()) {
  1457. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1458. if (file_exists($this->root . $file)) {
  1459. try {
  1460. touch($this->root . $file, filemtime($this->root . $file), time());
  1461. } catch (\ErrorException $e) {
  1462. Silencer::call('touch', $this->root . $file);
  1463. }
  1464. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1465. return copy($this->root . $file, $target);
  1466. }
  1467. }
  1468. return false;
  1469. }
  1470. public function gcIsNecessary()
  1471. {
  1472. if (self::$cacheCollected) {
  1473. return false;
  1474. }
  1475. self::$cacheCollected = true;
  1476. if (getenv('COMPOSER_TEST_SUITE')) {
  1477. return false;
  1478. }
  1479. if (PHP_VERSION_ID > 70000) {
  1480. return !random_int(0, 50);
  1481. }
  1482. return !mt_rand(0, 50);
  1483. }
  1484. public function remove($file)
  1485. {
  1486. if ($this->isEnabled()) {
  1487. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1488. if (file_exists($this->root . $file)) {
  1489. return $this->filesystem->unlink($this->root . $file);
  1490. }
  1491. }
  1492. return false;
  1493. }
  1494. public function clear()
  1495. {
  1496. if ($this->isEnabled()) {
  1497. $this->filesystem->emptyDirectory($this->root);
  1498. return true;
  1499. }
  1500. return false;
  1501. }
  1502. public function gc($ttl, $maxSize)
  1503. {
  1504. if ($this->isEnabled()) {
  1505. $expire = new \DateTime();
  1506. $expire->modify('-'.$ttl.' seconds');
  1507. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1508. foreach ($finder as $file) {
  1509. $this->filesystem->unlink($file->getPathname());
  1510. }
  1511. $totalSize = $this->filesystem->size($this->root);
  1512. if ($totalSize > $maxSize) {
  1513. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1514. while ($totalSize > $maxSize && $iterator->valid()) {
  1515. $filepath = $iterator->current()->getPathname();
  1516. $totalSize -= $this->filesystem->size($filepath);
  1517. $this->filesystem->unlink($filepath);
  1518. $iterator->next();
  1519. }
  1520. }
  1521. self::$cacheCollected = true;
  1522. return true;
  1523. }
  1524. return false;
  1525. }
  1526. public function sha1($file)
  1527. {
  1528. if ($this->isEnabled()) {
  1529. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1530. if (file_exists($this->root . $file)) {
  1531. return sha1_file($this->root . $file);
  1532. }
  1533. }
  1534. return false;
  1535. }
  1536. public function sha256($file)
  1537. {
  1538. if ($this->isEnabled()) {
  1539. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1540. if (file_exists($this->root . $file)) {
  1541. return hash_file('sha256', $this->root . $file);
  1542. }
  1543. }
  1544. return false;
  1545. }
  1546. protected function getFinder()
  1547. {
  1548. return Finder::create()->in($this->root)->files();
  1549. }
  1550. }
  1551. <?php
  1552. namespace Composer\Command;
  1553. use Composer\Composer;
  1554. use Symfony\Component\Console\Input\InputInterface;
  1555. use Symfony\Component\Console\Output\OutputInterface;
  1556. class AboutCommand extends BaseCommand
  1557. {
  1558. protected function configure()
  1559. {
  1560. $this
  1561. ->setName('about')
  1562. ->setDescription('Shows a short information about Composer.')
  1563. ->setHelp(
  1564. <<<EOT
  1565. <info>php composer.phar about</info>
  1566. EOT
  1567. )
  1568. ;
  1569. }
  1570. protected function execute(InputInterface $input, OutputInterface $output)
  1571. {
  1572. $composerVersion = Composer::getVersion();
  1573. $this->getIO()->write(
  1574. <<<EOT
  1575. <info>Composer - Dependency Manager for PHP - version $composerVersion</info>
  1576. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1577. See https://getcomposer.org/ for more information.</comment>
  1578. EOT
  1579. );
  1580. return 0;
  1581. }
  1582. }
  1583. <?php
  1584. namespace Composer\Command;
  1585. use Composer\Factory;
  1586. use Composer\IO\IOInterface;
  1587. use Composer\Config;
  1588. use Composer\Composer;
  1589. use Composer\Package\BasePackage;
  1590. use Composer\Package\CompletePackageInterface;
  1591. use Composer\Repository\CompositeRepository;
  1592. use Composer\Repository\RepositoryFactory;
  1593. use Composer\Script\ScriptEvents;
  1594. use Composer\Plugin\CommandEvent;
  1595. use Composer\Plugin\PluginEvents;
  1596. use Composer\Util\Filesystem;
  1597. use Composer\Util\Loop;
  1598. use Composer\Util\ProcessExecutor;
  1599. use Symfony\Component\Console\Input\InputArgument;
  1600. use Symfony\Component\Console\Input\InputInterface;
  1601. use Symfony\Component\Console\Input\InputOption;
  1602. use Symfony\Component\Console\Output\OutputInterface;
  1603. class ArchiveCommand extends BaseCommand
  1604. {
  1605. protected function configure()
  1606. {
  1607. $this
  1608. ->setName('archive')
  1609. ->setDescription('Creates an archive of this composer package.')
  1610. ->setDefinition(array(
  1611. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'),
  1612. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1613. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar or zip'),
  1614. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1615. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1616. .' Note that the format will be appended.'),
  1617. new InputOption('ignore-filters', null, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1618. ))
  1619. ->setHelp(
  1620. <<<EOT
  1621. The <info>archive</info> command creates an archive of the specified format
  1622. containing the files and directories of the Composer project or the specified
  1623. package in the specified version and writes it to the specified directory.
  1624. <info>php composer.phar archive [--format=zip] [--dir=/foo] [package [version]]</info>
  1625. Read more at https://getcomposer.org/doc/03-cli.md#archive
  1626. EOT
  1627. )
  1628. ;
  1629. }
  1630. protected function execute(InputInterface $input, OutputInterface $output)
  1631. {
  1632. $composer = $this->getComposer(false);
  1633. $config = null;
  1634. if ($composer) {
  1635. $config = $composer->getConfig();
  1636. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1637. $eventDispatcher = $composer->getEventDispatcher();
  1638. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1639. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1640. }
  1641. if (!$config) {
  1642. $config = Factory::createConfig();
  1643. }
  1644. if (null === $input->getOption('format')) {
  1645. $input->setOption('format', $config->get('archive-format'));
  1646. }
  1647. if (null === $input->getOption('dir')) {
  1648. $input->setOption('dir', $config->get('archive-dir'));
  1649. }
  1650. $returnCode = $this->archive(
  1651. $this->getIO(),
  1652. $config,
  1653. $input->getArgument('package'),
  1654. $input->getArgument('version'),
  1655. $input->getOption('format'),
  1656. $input->getOption('dir'),
  1657. $input->getOption('file'),
  1658. $input->getOption('ignore-filters'),
  1659. $composer
  1660. );
  1661. if (0 === $returnCode && $composer) {
  1662. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1663. }
  1664. return $returnCode;
  1665. }
  1666. protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters = false, Composer $composer = null)
  1667. {
  1668. if ($composer) {
  1669. $archiveManager = $composer->getArchiveManager();
  1670. } else {
  1671. $factory = new Factory;
  1672. $process = new ProcessExecutor();
  1673. $httpDownloader = Factory::createHttpDownloader($io, $config);
  1674. $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
  1675. $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
  1676. }
  1677. if ($packageName) {
  1678. $package = $this->selectPackage($io, $packageName, $version);
  1679. if (!$package) {
  1680. return 1;
  1681. }
  1682. } else {
  1683. $package = $this->getComposer()->getPackage();
  1684. }
  1685. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1686. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1687. $fs = new Filesystem;
  1688. $shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);
  1689. $io->writeError('Created: ', false);
  1690. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1691. return 0;
  1692. }
  1693. protected function selectPackage(IOInterface $io, $packageName, $version = null)
  1694. {
  1695. $io->writeError('<info>Searching for the specified package.</info>');
  1696. if ($composer = $this->getComposer(false)) {
  1697. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1698. $repo = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
  1699. } else {
  1700. $defaultRepos = RepositoryFactory::defaultRepos($this->getIO());
  1701. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1702. $repo = new CompositeRepository($defaultRepos);
  1703. }
  1704. $packages = $repo->findPackages($packageName, $version);
  1705. if (count($packages) > 1) {
  1706. $package = reset($packages);
  1707. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1708. $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) {
  1709. return $p->getPrettyString();
  1710. }, $packages)).'.');
  1711. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1712. } elseif ($packages) {
  1713. $package = reset($packages);
  1714. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1715. } else {
  1716. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1717. return false;
  1718. }
  1719. if (!$package instanceof CompletePackageInterface) {
  1720. throw new \LogicException('Expected a CompletePackageInterface instance but found '.get_class($package));
  1721. }
  1722. return $package;
  1723. }
  1724. }
  1725. <?php
  1726. namespace Composer\Command;
  1727. use Composer\Composer;
  1728. use Composer\Config;
  1729. use Composer\Console\Application;
  1730. use Composer\Factory;
  1731. use Composer\IO\IOInterface;
  1732. use Composer\IO\NullIO;
  1733. use Composer\Plugin\PreCommandRunEvent;
  1734. use Composer\Package\Version\VersionParser;
  1735. use Composer\Plugin\PluginEvents;
  1736. use Composer\Util\Platform;
  1737. use Symfony\Component\Console\Helper\Table;
  1738. use Symfony\Component\Console\Helper\TableSeparator;
  1739. use Symfony\Component\Console\Input\InputInterface;
  1740. use Symfony\Component\Console\Output\OutputInterface;
  1741. use Symfony\Component\Console\Command\Command;
  1742. use Symfony\Component\Console\Terminal;
  1743. abstract class BaseCommand extends Command
  1744. {
  1745. private $composer;
  1746. private $io;
  1747. public function getComposer($required = true, $disablePlugins = null)
  1748. {
  1749. if (null === $this->composer) {
  1750. $application = $this->getApplication();
  1751. if ($application instanceof Application) {
  1752. $this->composer = $application->getComposer($required, $disablePlugins);
  1753. } elseif ($required) {
  1754. throw new \RuntimeException(
  1755. 'Could not create a Composer\Composer instance, you must inject '.
  1756. 'one if this command is not used with a Composer\Console\Application instance'
  1757. );
  1758. }
  1759. }
  1760. return $this->composer;
  1761. }
  1762. public function setComposer(Composer $composer)
  1763. {
  1764. $this->composer = $composer;
  1765. }
  1766. public function resetComposer()
  1767. {
  1768. $this->composer = null;
  1769. $this->getApplication()->resetComposer();
  1770. }
  1771. public function isProxyCommand()
  1772. {
  1773. return false;
  1774. }
  1775. public function getIO()
  1776. {
  1777. if (null === $this->io) {
  1778. $application = $this->getApplication();
  1779. if ($application instanceof Application) {
  1780. $this->io = $application->getIO();
  1781. } else {
  1782. $this->io = new NullIO();
  1783. }
  1784. }
  1785. return $this->io;
  1786. }
  1787. public function setIO(IOInterface $io)
  1788. {
  1789. $this->io = $io;
  1790. }
  1791. protected function initialize(InputInterface $input, OutputInterface $output)
  1792. {
  1793. $disablePlugins = $input->hasParameterOption('--no-plugins');
  1794. $composer = $this->getComposer(false, $disablePlugins);
  1795. if (null === $composer) {
  1796. $composer = Factory::createGlobal($this->getIO(), $disablePlugins);
  1797. }
  1798. if ($composer) {
  1799. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  1800. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  1801. }
  1802. if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
  1803. $input->setOption('no-progress', true);
  1804. }
  1805. parent::initialize($input, $output);
  1806. }
  1807. protected function getPreferredInstallOptions(Config $config, InputInterface $input, $keepVcsRequiresPreferSource = false)
  1808. {
  1809. $preferSource = false;
  1810. $preferDist = false;
  1811. switch ($config->get('preferred-install')) {
  1812. case 'source':
  1813. $preferSource = true;
  1814. break;
  1815. case 'dist':
  1816. $preferDist = true;
  1817. break;
  1818. case 'auto':
  1819. default:
  1820. break;
  1821. }
  1822. if ($input->hasOption('prefer-install') && $input->getOption('prefer-install')) {
  1823. if ($input->getOption('prefer-source')) {
  1824. throw new \InvalidArgumentException('--prefer-source can not be used together with --prefer-install');
  1825. }
  1826. if ($input->getOption('prefer-dist')) {
  1827. throw new \InvalidArgumentException('--prefer-dist can not be used together with --prefer-install');
  1828. }
  1829. switch ($input->getOption('prefer-install')) {
  1830. case 'dist':
  1831. $input->setOption('prefer-dist', true);
  1832. break;
  1833. case 'source':
  1834. $input->setOption('prefer-source', true);
  1835. break;
  1836. case 'auto':
  1837. $preferDist = false;
  1838. $preferSource = false;
  1839. break;
  1840. default:
  1841. throw new \UnexpectedValueException('--prefer-install accepts one of "dist", "source" or "auto", got '.$input->getOption('prefer-install'));
  1842. }
  1843. }
  1844. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  1845. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  1846. $preferDist = (bool) $input->getOption('prefer-dist');
  1847. }
  1848. return array($preferSource, $preferDist);
  1849. }
  1850. protected function formatRequirements(array $requirements)
  1851. {
  1852. $requires = array();
  1853. $requirements = $this->normalizeRequirements($requirements);
  1854. foreach ($requirements as $requirement) {
  1855. if (!isset($requirement['version'])) {
  1856. throw new \UnexpectedValueException('Option '.$requirement['name'] .' is missing a version constraint, use e.g. '.$requirement['name'].':^1.0');
  1857. }
  1858. $requires[$requirement['name']] = $requirement['version'];
  1859. }
  1860. return $requires;
  1861. }
  1862. protected function normalizeRequirements(array $requirements)
  1863. {
  1864. $parser = new VersionParser();
  1865. return $parser->parseNameVersionPairs($requirements);
  1866. }
  1867. protected function renderTable(array $table, OutputInterface $output)
  1868. {
  1869. $renderer = new Table($output);
  1870. $renderer->setStyle('compact');
  1871. $rendererStyle = $renderer->getStyle();
  1872. if (method_exists($rendererStyle, 'setVerticalBorderChars')) {
  1873. $rendererStyle->setVerticalBorderChars('');
  1874. } else {
  1875. $rendererStyle->setVerticalBorderChar('');
  1876. }
  1877. $rendererStyle->setCellRowContentFormat('%s ');
  1878. $renderer->setRows($table)->render();
  1879. }
  1880. protected function getTerminalWidth()
  1881. {
  1882. if (class_exists('Symfony\Component\Console\Terminal')) {
  1883. $terminal = new Terminal();
  1884. $width = $terminal->getWidth();
  1885. } else {
  1886. list($width) = $this->getApplication()->getTerminalDimensions();
  1887. }
  1888. if (null === $width) {
  1889. $width = PHP_INT_MAX;
  1890. }
  1891. if (Platform::isWindows()) {
  1892. $width--;
  1893. } else {
  1894. $width = max(80, $width);
  1895. }
  1896. return $width;
  1897. }
  1898. }
  1899. <?php
  1900. namespace Composer\Command;
  1901. use Composer\Package\Link;
  1902. use Composer\Package\PackageInterface;
  1903. use Composer\Package\CompletePackageInterface;
  1904. use Composer\Package\RootPackage;
  1905. use Composer\Repository\InstalledArrayRepository;
  1906. use Composer\Repository\CompositeRepository;
  1907. use Composer\Repository\RootPackageRepository;
  1908. use Composer\Repository\InstalledRepository;
  1909. use Composer\Repository\PlatformRepository;
  1910. use Composer\Repository\RepositoryFactory;
  1911. use Composer\Plugin\CommandEvent;
  1912. use Composer\Plugin\PluginEvents;
  1913. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  1914. use Composer\Package\Version\VersionParser;
  1915. use Symfony\Component\Console\Input\InputInterface;
  1916. use Symfony\Component\Console\Output\OutputInterface;
  1917. class BaseDependencyCommand extends BaseCommand
  1918. {
  1919. const ARGUMENT_PACKAGE = 'package';
  1920. const ARGUMENT_CONSTRAINT = 'version';
  1921. const OPTION_RECURSIVE = 'recursive';
  1922. const OPTION_TREE = 'tree';
  1923. protected $colors;
  1924. protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
  1925. {
  1926. $composer = $this->getComposer();
  1927. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  1928. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  1929. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  1930. $installedRepo = new InstalledRepository(array(
  1931. new RootPackageRepository($composer->getPackage()),
  1932. $composer->getRepositoryManager()->getLocalRepository(),
  1933. new PlatformRepository(array(), $platformOverrides),
  1934. ));
  1935. list($needle, $textConstraint) = array_pad(
  1936. explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)),
  1937. 2,
  1938. $input->hasArgument(self::ARGUMENT_CONSTRAINT) ? $input->getArgument(self::ARGUMENT_CONSTRAINT) : '*'
  1939. );
  1940. $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
  1941. if (empty($packages)) {
  1942. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  1943. }
  1944. if (!$installedRepo->findPackage($needle, $textConstraint)) {
  1945. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
  1946. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  1947. $installedRepo->addRepository(new InstalledArrayRepository(array(clone $match)));
  1948. }
  1949. }
  1950. $needles = array($needle);
  1951. if ($inverted) {
  1952. foreach ($packages as $package) {
  1953. $needles = array_merge($needles, array_map(function (Link $link) {
  1954. return $link->getTarget();
  1955. }, $package->getReplaces()));
  1956. }
  1957. }
  1958. if ('*' !== $textConstraint) {
  1959. $versionParser = new VersionParser();
  1960. $constraint = $versionParser->parseConstraints($textConstraint);
  1961. } else {
  1962. $constraint = null;
  1963. }
  1964. $renderTree = $input->getOption(self::OPTION_TREE);
  1965. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  1966. $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive);
  1967. if (empty($results)) {
  1968. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  1969. $this->getIO()->writeError(sprintf(
  1970. '<info>There is no installed package depending on "%s"%s</info>',
  1971. $needle,
  1972. $extra
  1973. ));
  1974. } elseif ($renderTree) {
  1975. $this->initStyles($output);
  1976. $root = $packages[0];
  1977. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root instanceof CompletePackageInterface ? $root->getDescription() : ''));
  1978. $this->printTree($results);
  1979. } else {
  1980. $this->printTable($output, $results);
  1981. }
  1982. return 0;
  1983. }
  1984. protected function printTable(OutputInterface $output, $results)
  1985. {
  1986. $table = array();
  1987. $doubles = array();
  1988. do {
  1989. $queue = array();
  1990. $rows = array();
  1991. foreach ($results as $result) {
  1992. list($package, $link, $children) = $result;
  1993. $unique = (string) $link;
  1994. if (isset($doubles[$unique])) {
  1995. continue;
  1996. }
  1997. $doubles[$unique] = true;
  1998. $version = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '-' : $package->getPrettyVersion();
  1999. $rows[] = array($package->getPrettyName(), $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint()));
  2000. if ($children) {
  2001. $queue = array_merge($queue, $children);
  2002. }
  2003. }
  2004. $results = $queue;
  2005. $table = array_merge($rows, $table);
  2006. } while (!empty($results));
  2007. $this->renderTable($table, $output);
  2008. }
  2009. protected function initStyles(OutputInterface $output)
  2010. {
  2011. $this->colors = array(
  2012. 'green',
  2013. 'yellow',
  2014. 'cyan',
  2015. 'magenta',
  2016. 'blue',
  2017. );
  2018. foreach ($this->colors as $color) {
  2019. $style = new OutputFormatterStyle($color);
  2020. $output->getFormatter()->setStyle($color, $style);
  2021. }
  2022. }
  2023. protected function printTree($results, $prefix = '', $level = 1)
  2024. {
  2025. $count = count($results);
  2026. $idx = 0;
  2027. foreach ($results as $result) {
  2028. list($package, $link, $children) = $result;
  2029. $color = $this->colors[$level % count($this->colors)];
  2030. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  2031. $isLast = (++$idx == $count);
  2032. $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion();
  2033. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText));
  2034. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  2035. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  2036. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  2037. if ($children) {
  2038. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  2039. }
  2040. }
  2041. }
  2042. private function writeTreeLine($line)
  2043. {
  2044. $io = $this->getIO();
  2045. if (!$io->isDecorated()) {
  2046. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  2047. }
  2048. $io->write($line);
  2049. }
  2050. }
  2051. <?php
  2052. namespace Composer\Command;
  2053. use Composer\Package\Link;
  2054. use Composer\Semver\Constraint\Constraint;
  2055. use Symfony\Component\Console\Input\InputInterface;
  2056. use Symfony\Component\Console\Input\InputOption;
  2057. use Symfony\Component\Console\Output\OutputInterface;
  2058. use Composer\Repository\PlatformRepository;
  2059. use Composer\Repository\RootPackageRepository;
  2060. use Composer\Repository\InstalledRepository;
  2061. class CheckPlatformReqsCommand extends BaseCommand
  2062. {
  2063. protected function configure()
  2064. {
  2065. $this->setName('check-platform-reqs')
  2066. ->setDescription('Check that platform requirements are satisfied.')
  2067. ->setDefinition(array(
  2068. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  2069. new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
  2070. ))
  2071. ->setHelp(
  2072. <<<EOT
  2073. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  2074. 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.
  2075. <info>php composer.phar check-platform-reqs</info>
  2076. EOT
  2077. );
  2078. }
  2079. protected function execute(InputInterface $input, OutputInterface $output)
  2080. {
  2081. $composer = $this->getComposer();
  2082. $requires = array();
  2083. $removePackages = array();
  2084. if ($input->getOption('lock')) {
  2085. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
  2086. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2087. } else {
  2088. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  2089. if (!$installedRepo->getPackages()) {
  2090. $this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
  2091. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2092. } else {
  2093. if ($input->getOption('no-dev')) {
  2094. $removePackages = $installedRepo->getDevPackageNames();
  2095. }
  2096. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
  2097. }
  2098. }
  2099. if (!$input->getOption('no-dev')) {
  2100. $requires += $composer->getPackage()->getDevRequires();
  2101. }
  2102. foreach ($requires as $require => $link) {
  2103. $requires[$require] = array($link);
  2104. }
  2105. $installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage())));
  2106. foreach ($installedRepo->getPackages() as $package) {
  2107. if (in_array($package->getName(), $removePackages, true)) {
  2108. continue;
  2109. }
  2110. foreach ($package->getRequires() as $require => $link) {
  2111. $requires[$require][] = $link;
  2112. }
  2113. }
  2114. ksort($requires);
  2115. $installedRepo->addRepository(new PlatformRepository(array(), array()));
  2116. $results = array();
  2117. $exitCode = 0;
  2118. foreach ($requires as $require => $links) {
  2119. if (PlatformRepository::isPlatformPackage($require)) {
  2120. $candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
  2121. if ($candidates) {
  2122. $reqResults = array();
  2123. foreach ($candidates as $candidate) {
  2124. $candidateConstraint = null;
  2125. if ($candidate->getName() === $require) {
  2126. $candidateConstraint = new Constraint('=', $candidate->getVersion());
  2127. $candidateConstraint->setPrettyString($candidate->getPrettyVersion());
  2128. } else {
  2129. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  2130. if ($link->getTarget() === $require) {
  2131. $candidateConstraint = $link->getConstraint();
  2132. break;
  2133. }
  2134. }
  2135. }
  2136. if (!$candidateConstraint) {
  2137. continue;
  2138. }
  2139. foreach ($links as $link) {
  2140. if (!$link->getConstraint()->matches($candidateConstraint)) {
  2141. $reqResults[] = array(
  2142. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2143. $candidateConstraint->getPrettyString(),
  2144. $link,
  2145. '<error>failed</error>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  2146. );
  2147. continue 2;
  2148. }
  2149. }
  2150. $results[] = array(
  2151. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2152. $candidateConstraint->getPrettyString(),
  2153. null,
  2154. '<info>success</info>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  2155. );
  2156. continue 2;
  2157. }
  2158. $results = array_merge($results, $reqResults);
  2159. $exitCode = max($exitCode, 1);
  2160. continue;
  2161. }
  2162. $results[] = array(
  2163. $require,
  2164. 'n/a',
  2165. $links[0],
  2166. '<error>missing</error>',
  2167. );
  2168. $exitCode = max($exitCode, 2);
  2169. }
  2170. }
  2171. $this->printTable($output, $results);
  2172. return $exitCode;
  2173. }
  2174. protected function printTable(OutputInterface $output, $results)
  2175. {
  2176. $rows = array();
  2177. foreach ($results as $result) {
  2178. list($platformPackage, $version, $link, $status) = $result;
  2179. $rows[] = array(
  2180. $platformPackage,
  2181. $version,
  2182. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  2183. $status,
  2184. );
  2185. }
  2186. $this->renderTable($rows, $output);
  2187. }
  2188. }
  2189. <?php
  2190. namespace Composer\Command;
  2191. use Composer\Cache;
  2192. use Composer\Factory;
  2193. use Symfony\Component\Console\Input\InputInterface;
  2194. use Symfony\Component\Console\Output\OutputInterface;
  2195. class ClearCacheCommand extends BaseCommand
  2196. {
  2197. protected function configure()
  2198. {
  2199. $this
  2200. ->setName('clear-cache')
  2201. ->setAliases(array('clearcache', 'cc'))
  2202. ->setDescription('Clears composer\'s internal package cache.')
  2203. ->setHelp(
  2204. <<<EOT
  2205. The <info>clear-cache</info> deletes all cached packages from composer's
  2206. cache directory.
  2207. Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc
  2208. EOT
  2209. )
  2210. ;
  2211. }
  2212. protected function execute(InputInterface $input, OutputInterface $output)
  2213. {
  2214. $config = Factory::createConfig();
  2215. $io = $this->getIO();
  2216. $cachePaths = array(
  2217. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  2218. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  2219. 'cache-files-dir' => $config->get('cache-files-dir'),
  2220. 'cache-dir' => $config->get('cache-dir'),
  2221. );
  2222. foreach ($cachePaths as $key => $cachePath) {
  2223. $cachePath = realpath($cachePath);
  2224. if (!$cachePath) {
  2225. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  2226. continue;
  2227. }
  2228. $cache = new Cache($io, $cachePath);
  2229. $cache->setReadOnly($config->get('cache-read-only'));
  2230. if (!$cache->isEnabled()) {
  2231. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  2232. continue;
  2233. }
  2234. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  2235. $cache->clear();
  2236. }
  2237. $io->writeError('<info>All caches cleared.</info>');
  2238. return 0;
  2239. }
  2240. }
  2241. <?php
  2242. namespace Composer\Command;
  2243. use Composer\Util\Filesystem;
  2244. use Composer\Util\Platform;
  2245. use Composer\Util\Silencer;
  2246. use Symfony\Component\Console\Input\InputInterface;
  2247. use Symfony\Component\Console\Input\InputArgument;
  2248. use Symfony\Component\Console\Input\InputOption;
  2249. use Symfony\Component\Console\Output\OutputInterface;
  2250. use Composer\Config;
  2251. use Composer\Config\JsonConfigSource;
  2252. use Composer\Factory;
  2253. use Composer\IO\IOInterface;
  2254. use Composer\Json\JsonFile;
  2255. use Composer\Semver\VersionParser;
  2256. use Composer\Package\BasePackage;
  2257. class ConfigCommand extends BaseCommand
  2258. {
  2259. protected $config;
  2260. protected $configFile;
  2261. protected $configSource;
  2262. protected $authConfigFile;
  2263. protected $authConfigSource;
  2264. protected function configure()
  2265. {
  2266. $this
  2267. ->setName('config')
  2268. ->setDescription('Sets config options.')
  2269. ->setDefinition(array(
  2270. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  2271. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  2272. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  2273. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  2274. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  2275. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  2276. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  2277. new InputOption('json', 'j', InputOption::VALUE_NONE, 'JSON decode the setting value, to be used with extra.* keys'),
  2278. 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'),
  2279. 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)'),
  2280. new InputArgument('setting-key', null, 'Setting key'),
  2281. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  2282. ))
  2283. ->setHelp(
  2284. <<<EOT
  2285. This command allows you to edit composer config settings and repositories
  2286. in either the local composer.json file or the global config.json file.
  2287. Additionally it lets you edit most properties in the local composer.json.
  2288. To set a config setting:
  2289. <comment>%command.full_name% bin-dir bin/</comment>
  2290. To read a config setting:
  2291. <comment>%command.full_name% bin-dir</comment>
  2292. Outputs: <info>bin</info>
  2293. To edit the global config.json file:
  2294. <comment>%command.full_name% --global</comment>
  2295. To add a repository:
  2296. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  2297. To remove a repository (repo is a short alias for repositories):
  2298. <comment>%command.full_name% --unset repo.foo</comment>
  2299. To disable packagist:
  2300. <comment>%command.full_name% repo.packagist false</comment>
  2301. You can alter repositories in the global config.json file by passing in the
  2302. <info>--global</info> option.
  2303. To add or edit suggested packages you can use:
  2304. <comment>%command.full_name% suggest.package reason for the suggestion</comment>
  2305. To add or edit extra properties you can use:
  2306. <comment>%command.full_name% extra.property value</comment>
  2307. Or to add a complex value you can use json with:
  2308. <comment>%command.full_name% extra.property --json '{"foo":true, "bar": []}'</comment>
  2309. To edit the file in an external editor:
  2310. <comment>%command.full_name% --editor</comment>
  2311. To choose your editor you can set the "EDITOR" env variable.
  2312. To get a list of configuration values in the file:
  2313. <comment>%command.full_name% --list</comment>
  2314. You can always pass more than one option. As an example, if you want to edit the
  2315. global config.json file.
  2316. <comment>%command.full_name% --editor --global</comment>
  2317. Read more at https://getcomposer.org/doc/03-cli.md#config
  2318. EOT
  2319. )
  2320. ;
  2321. }
  2322. protected function initialize(InputInterface $input, OutputInterface $output)
  2323. {
  2324. parent::initialize($input, $output);
  2325. if ($input->getOption('global') && null !== $input->getOption('file')) {
  2326. throw new \RuntimeException('--file and --global can not be combined');
  2327. }
  2328. $io = $this->getIO();
  2329. $this->config = Factory::createConfig($io);
  2330. $configFile = $input->getOption('global')
  2331. ? ($this->config->get('home') . '/config.json')
  2332. : ($input->getOption('file') ?: Factory::getComposerFile());
  2333. if (
  2334. ($configFile === 'composer.json' || $configFile === './composer.json')
  2335. && !file_exists($configFile)
  2336. && realpath(getcwd()) === realpath($this->config->get('home'))
  2337. ) {
  2338. file_put_contents($configFile, "{\n}\n");
  2339. }
  2340. $this->configFile = new JsonFile($configFile, null, $io);
  2341. $this->configSource = new JsonConfigSource($this->configFile);
  2342. $authConfigFile = $input->getOption('global')
  2343. ? ($this->config->get('home') . '/auth.json')
  2344. : dirname(realpath($configFile)) . '/auth.json';
  2345. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  2346. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  2347. if ($input->getOption('global') && !$this->configFile->exists()) {
  2348. touch($this->configFile->getPath());
  2349. $this->configFile->write(array('config' => new \ArrayObject));
  2350. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  2351. }
  2352. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  2353. touch($this->authConfigFile->getPath());
  2354. $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));
  2355. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  2356. }
  2357. if (!$this->configFile->exists()) {
  2358. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  2359. }
  2360. }
  2361. protected function execute(InputInterface $input, OutputInterface $output)
  2362. {
  2363. if ($input->getOption('editor')) {
  2364. $editor = escapeshellcmd(getenv('EDITOR'));
  2365. if (!$editor) {
  2366. if (Platform::isWindows()) {
  2367. $editor = 'notepad';
  2368. } else {
  2369. foreach (array('editor', 'vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
  2370. if (exec('which '.$candidate)) {
  2371. $editor = $candidate;
  2372. break;
  2373. }
  2374. }
  2375. }
  2376. }
  2377. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  2378. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  2379. return 0;
  2380. }
  2381. if (!$input->getOption('global')) {
  2382. $this->config->merge($this->configFile->read());
  2383. $this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()));
  2384. }
  2385. if ($input->getOption('list')) {
  2386. $this->listConfiguration($this->config->all(), $this->config->raw(), $output);
  2387. return 0;
  2388. }
  2389. $settingKey = $input->getArgument('setting-key');
  2390. if (!$settingKey || !is_string($settingKey)) {
  2391. return 0;
  2392. }
  2393. if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  2394. throw new \RuntimeException('You can not combine a setting value with --unset');
  2395. }
  2396. if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  2397. $properties = array('name', 'type', 'description', 'homepage', 'version', 'minimum-stability', 'prefer-stable', 'keywords', 'license', 'extra');
  2398. $rawData = $this->configFile->read();
  2399. $data = $this->config->all();
  2400. if (preg_match('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  2401. if (!isset($matches[1]) || $matches[1] === '') {
  2402. $value = isset($data['repositories']) ? $data['repositories'] : array();
  2403. } else {
  2404. if (!isset($data['repositories'][$matches[1]])) {
  2405. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  2406. }
  2407. $value = $data['repositories'][$matches[1]];
  2408. }
  2409. } elseif (strpos($settingKey, '.')) {
  2410. $bits = explode('.', $settingKey);
  2411. if ($bits[0] === 'extra') {
  2412. $data = $rawData;
  2413. } else {
  2414. $data = $data['config'];
  2415. }
  2416. $match = false;
  2417. foreach ($bits as $bit) {
  2418. $key = isset($key) ? $key.'.'.$bit : $bit;
  2419. $match = false;
  2420. if (isset($data[$key])) {
  2421. $match = true;
  2422. $data = $data[$key];
  2423. unset($key);
  2424. }
  2425. }
  2426. if (!$match) {
  2427. throw new \RuntimeException($settingKey.' is not defined.');
  2428. }
  2429. $value = $data;
  2430. } elseif (isset($data['config'][$settingKey])) {
  2431. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  2432. } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
  2433. $value = $rawData[$settingKey];
  2434. } else {
  2435. throw new \RuntimeException($settingKey.' is not defined');
  2436. }
  2437. if (is_array($value)) {
  2438. $value = json_encode($value);
  2439. }
  2440. $this->getIO()->write($value, true, IOInterface::QUIET);
  2441. return 0;
  2442. }
  2443. $values = $input->getArgument('setting-value');
  2444. $booleanValidator = function ($val) {
  2445. return in_array($val, array('true', 'false', '1', '0'), true);
  2446. };
  2447. $booleanNormalizer = function ($val) {
  2448. return $val !== 'false' && (bool) $val;
  2449. };
  2450. $uniqueConfigValues = array(
  2451. 'process-timeout' => array('is_numeric', 'intval'),
  2452. 'use-include-path' => array($booleanValidator, $booleanNormalizer),
  2453. 'use-github-api' => array($booleanValidator, $booleanNormalizer),
  2454. 'preferred-install' => array(
  2455. function ($val) {
  2456. return in_array($val, array('auto', 'source', 'dist'), true);
  2457. },
  2458. function ($val) {
  2459. return $val;
  2460. },
  2461. ),
  2462. 'gitlab-protocol' => array(
  2463. function ($val) {
  2464. return in_array($val, array('git', 'http', 'https'), true);
  2465. },
  2466. function ($val) {
  2467. return $val;
  2468. },
  2469. ),
  2470. 'store-auths' => array(
  2471. function ($val) {
  2472. return in_array($val, array('true', 'false', 'prompt'), true);
  2473. },
  2474. function ($val) {
  2475. if ('prompt' === $val) {
  2476. return 'prompt';
  2477. }
  2478. return $val !== 'false' && (bool) $val;
  2479. },
  2480. ),
  2481. 'notify-on-install' => array($booleanValidator, $booleanNormalizer),
  2482. 'vendor-dir' => array('is_string', function ($val) {
  2483. return $val;
  2484. }),
  2485. 'bin-dir' => array('is_string', function ($val) {
  2486. return $val;
  2487. }),
  2488. 'archive-dir' => array('is_string', function ($val) {
  2489. return $val;
  2490. }),
  2491. 'archive-format' => array('is_string', function ($val) {
  2492. return $val;
  2493. }),
  2494. 'data-dir' => array('is_string', function ($val) {
  2495. return $val;
  2496. }),
  2497. 'cache-dir' => array('is_string', function ($val) {
  2498. return $val;
  2499. }),
  2500. 'cache-files-dir' => array('is_string', function ($val) {
  2501. return $val;
  2502. }),
  2503. 'cache-repo-dir' => array('is_string', function ($val) {
  2504. return $val;
  2505. }),
  2506. 'cache-vcs-dir' => array('is_string', function ($val) {
  2507. return $val;
  2508. }),
  2509. 'cache-ttl' => array('is_numeric', 'intval'),
  2510. 'cache-files-ttl' => array('is_numeric', 'intval'),
  2511. 'cache-files-maxsize' => array(
  2512. function ($val) {
  2513. return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0;
  2514. },
  2515. function ($val) {
  2516. return $val;
  2517. },
  2518. ),
  2519. 'bin-compat' => array(
  2520. function ($val) {
  2521. return in_array($val, array('auto', 'full', 'symlink'));
  2522. },
  2523. function ($val) {
  2524. return $val;
  2525. },
  2526. ),
  2527. 'discard-changes' => array(
  2528. function ($val) {
  2529. return in_array($val, array('stash', 'true', 'false', '1', '0'), true);
  2530. },
  2531. function ($val) {
  2532. if ('stash' === $val) {
  2533. return 'stash';
  2534. }
  2535. return $val !== 'false' && (bool) $val;
  2536. },
  2537. ),
  2538. 'autoloader-suffix' => array('is_string', function ($val) {
  2539. return $val === 'null' ? null : $val;
  2540. }),
  2541. 'sort-packages' => array($booleanValidator, $booleanNormalizer),
  2542. 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
  2543. 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
  2544. 'apcu-autoloader' => array($booleanValidator, $booleanNormalizer),
  2545. 'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
  2546. 'disable-tls' => array($booleanValidator, $booleanNormalizer),
  2547. 'secure-http' => array($booleanValidator, $booleanNormalizer),
  2548. 'cafile' => array(
  2549. function ($val) {
  2550. return file_exists($val) && Filesystem::isReadable($val);
  2551. },
  2552. function ($val) {
  2553. return $val === 'null' ? null : $val;
  2554. },
  2555. ),
  2556. 'capath' => array(
  2557. function ($val) {
  2558. return is_dir($val) && Filesystem::isReadable($val);
  2559. },
  2560. function ($val) {
  2561. return $val === 'null' ? null : $val;
  2562. },
  2563. ),
  2564. 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
  2565. 'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
  2566. 'lock' => array($booleanValidator, $booleanNormalizer),
  2567. 'platform-check' => array(
  2568. function ($val) {
  2569. return in_array($val, array('php-only', 'true', 'false', '1', '0'), true);
  2570. },
  2571. function ($val) {
  2572. if ('php-only' === $val) {
  2573. return 'php-only';
  2574. }
  2575. return $val !== 'false' && (bool) $val;
  2576. },
  2577. ),
  2578. );
  2579. $multiConfigValues = array(
  2580. 'github-protocols' => array(
  2581. function ($vals) {
  2582. if (!is_array($vals)) {
  2583. return 'array expected';
  2584. }
  2585. foreach ($vals as $val) {
  2586. if (!in_array($val, array('git', 'https', 'ssh'))) {
  2587. return 'valid protocols include: git, https, ssh';
  2588. }
  2589. }
  2590. return true;
  2591. },
  2592. function ($vals) {
  2593. return $vals;
  2594. },
  2595. ),
  2596. 'github-domains' => array(
  2597. function ($vals) {
  2598. if (!is_array($vals)) {
  2599. return 'array expected';
  2600. }
  2601. return true;
  2602. },
  2603. function ($vals) {
  2604. return $vals;
  2605. },
  2606. ),
  2607. 'gitlab-domains' => array(
  2608. function ($vals) {
  2609. if (!is_array($vals)) {
  2610. return 'array expected';
  2611. }
  2612. return true;
  2613. },
  2614. function ($vals) {
  2615. return $vals;
  2616. },
  2617. ),
  2618. );
  2619. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  2620. if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
  2621. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2622. }
  2623. $this->configSource->removeConfigSetting($settingKey);
  2624. return 0;
  2625. }
  2626. if (isset($uniqueConfigValues[$settingKey])) {
  2627. $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  2628. return 0;
  2629. }
  2630. if (isset($multiConfigValues[$settingKey])) {
  2631. $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  2632. return 0;
  2633. }
  2634. if (preg_match('/^preferred-install\.(.+)/', $settingKey, $matches)) {
  2635. if ($input->getOption('unset')) {
  2636. $this->configSource->removeConfigSetting($settingKey);
  2637. return 0;
  2638. }
  2639. list($validator) = $uniqueConfigValues['preferred-install'];
  2640. if (!$validator($values[0])) {
  2641. throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
  2642. }
  2643. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2644. return 0;
  2645. }
  2646. $uniqueProps = array(
  2647. 'name' => array('is_string', function ($val) {
  2648. return $val;
  2649. }),
  2650. 'type' => array('is_string', function ($val) {
  2651. return $val;
  2652. }),
  2653. 'description' => array('is_string', function ($val) {
  2654. return $val;
  2655. }),
  2656. 'homepage' => array('is_string', function ($val) {
  2657. return $val;
  2658. }),
  2659. 'version' => array('is_string', function ($val) {
  2660. return $val;
  2661. }),
  2662. 'minimum-stability' => array(
  2663. function ($val) {
  2664. return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
  2665. },
  2666. function ($val) {
  2667. return VersionParser::normalizeStability($val);
  2668. },
  2669. ),
  2670. 'prefer-stable' => array($booleanValidator, $booleanNormalizer),
  2671. );
  2672. $multiProps = array(
  2673. 'keywords' => array(
  2674. function ($vals) {
  2675. if (!is_array($vals)) {
  2676. return 'array expected';
  2677. }
  2678. return true;
  2679. },
  2680. function ($vals) {
  2681. return $vals;
  2682. },
  2683. ),
  2684. 'license' => array(
  2685. function ($vals) {
  2686. if (!is_array($vals)) {
  2687. return 'array expected';
  2688. }
  2689. return true;
  2690. },
  2691. function ($vals) {
  2692. return $vals;
  2693. },
  2694. ),
  2695. );
  2696. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
  2697. 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');
  2698. }
  2699. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  2700. $this->configSource->removeProperty($settingKey);
  2701. return 0;
  2702. }
  2703. if (isset($uniqueProps[$settingKey])) {
  2704. $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  2705. return 0;
  2706. }
  2707. if (isset($multiProps[$settingKey])) {
  2708. $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  2709. return 0;
  2710. }
  2711. if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  2712. if ($input->getOption('unset')) {
  2713. $this->configSource->removeRepository($matches[1]);
  2714. return 0;
  2715. }
  2716. if (2 === count($values)) {
  2717. $this->configSource->addRepository($matches[1], array(
  2718. 'type' => $values[0],
  2719. 'url' => $values[1],
  2720. ), $input->getOption('append'));
  2721. return 0;
  2722. }
  2723. if (1 === count($values)) {
  2724. $value = strtolower($values[0]);
  2725. if (true === $booleanValidator($value)) {
  2726. if (false === $booleanNormalizer($value)) {
  2727. $this->configSource->addRepository($matches[1], false, $input->getOption('append'));
  2728. return 0;
  2729. }
  2730. } else {
  2731. $value = JsonFile::parseJson($values[0]);
  2732. $this->configSource->addRepository($matches[1], $value, $input->getOption('append'));
  2733. return 0;
  2734. }
  2735. }
  2736. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  2737. }
  2738. if (preg_match('/^extra\.(.+)/', $settingKey, $matches)) {
  2739. if ($input->getOption('unset')) {
  2740. $this->configSource->removeProperty($settingKey);
  2741. return 0;
  2742. }
  2743. $value = $values[0];
  2744. if ($input->getOption('json')) {
  2745. $value = JsonFile::parseJson($value);
  2746. if ($input->getOption('merge')) {
  2747. $currentValue = $this->configFile->read();
  2748. $bits = explode('.', $settingKey);
  2749. foreach ($bits as $bit) {
  2750. $currentValue = isset($currentValue[$bit]) ? $currentValue[$bit] : null;
  2751. }
  2752. if (is_array($currentValue)) {
  2753. $value = array_merge($currentValue, $value);
  2754. }
  2755. }
  2756. }
  2757. $this->configSource->addProperty($settingKey, $value);
  2758. return 0;
  2759. }
  2760. if (preg_match('/^suggest\.(.+)/', $settingKey, $matches)) {
  2761. if ($input->getOption('unset')) {
  2762. $this->configSource->removeProperty($settingKey);
  2763. return 0;
  2764. }
  2765. $this->configSource->addProperty($settingKey, implode(' ', $values));
  2766. return 0;
  2767. }
  2768. if (in_array($settingKey, array('suggest', 'extra'), true) && $input->getOption('unset')) {
  2769. $this->configSource->removeProperty($settingKey);
  2770. return 0;
  2771. }
  2772. if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
  2773. if ($input->getOption('unset')) {
  2774. $this->configSource->removeConfigSetting($settingKey);
  2775. return 0;
  2776. }
  2777. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2778. return 0;
  2779. }
  2780. if ($settingKey === 'platform' && $input->getOption('unset')) {
  2781. $this->configSource->removeConfigSetting($settingKey);
  2782. return 0;
  2783. }
  2784. if (preg_match('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
  2785. if ($input->getOption('unset')) {
  2786. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2787. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2788. return 0;
  2789. }
  2790. if ($matches[1] === 'bitbucket-oauth') {
  2791. if (2 !== count($values)) {
  2792. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  2793. }
  2794. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2795. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
  2796. } elseif ($matches[1] === 'gitlab-token' && 2 === count($values)) {
  2797. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2798. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'token' => $values[1]));
  2799. } elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'), true)) {
  2800. if (1 !== count($values)) {
  2801. throw new \RuntimeException('Too many arguments, expected only one token');
  2802. }
  2803. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2804. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  2805. } elseif ($matches[1] === 'http-basic') {
  2806. if (2 !== count($values)) {
  2807. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  2808. }
  2809. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2810. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
  2811. }
  2812. return 0;
  2813. }
  2814. if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)) {
  2815. if ($input->getOption('unset')) {
  2816. $this->configSource->removeProperty($settingKey);
  2817. return 0;
  2818. }
  2819. $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  2820. return 0;
  2821. }
  2822. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  2823. }
  2824. protected function handleSingleValue($key, array $callbacks, array $values, $method)
  2825. {
  2826. list($validator, $normalizer) = $callbacks;
  2827. if (1 !== count($values)) {
  2828. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  2829. }
  2830. if (true !== $validation = $validator($values[0])) {
  2831. throw new \RuntimeException(sprintf(
  2832. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2833. $values[0]
  2834. ));
  2835. }
  2836. $normalizedValue = $normalizer($values[0]);
  2837. if ($key === 'disable-tls') {
  2838. if (!$normalizedValue && $this->config->get('disable-tls')) {
  2839. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2840. } elseif ($normalizedValue && !$this->config->get('disable-tls')) {
  2841. $this->getIO()->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
  2842. }
  2843. }
  2844. call_user_func(array($this->configSource, $method), $key, $normalizedValue);
  2845. }
  2846. protected function handleMultiValue($key, array $callbacks, array $values, $method)
  2847. {
  2848. list($validator, $normalizer) = $callbacks;
  2849. if (true !== $validation = $validator($values)) {
  2850. throw new \RuntimeException(sprintf(
  2851. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2852. json_encode($values)
  2853. ));
  2854. }
  2855. call_user_func(array($this->configSource, $method), $key, $normalizer($values));
  2856. }
  2857. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
  2858. {
  2859. $origK = $k;
  2860. $io = $this->getIO();
  2861. foreach ($contents as $key => $value) {
  2862. if ($k === null && !in_array($key, array('config', 'repositories'))) {
  2863. continue;
  2864. }
  2865. $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
  2866. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  2867. $k .= preg_replace('{^config\.}', '', $key . '.');
  2868. $this->listConfiguration($value, $rawVal, $output, $k);
  2869. $k = $origK;
  2870. continue;
  2871. }
  2872. if (is_array($value)) {
  2873. $value = array_map(function ($val) {
  2874. return is_array($val) ? json_encode($val) : $val;
  2875. }, $value);
  2876. $value = '['.implode(', ', $value).']';
  2877. }
  2878. if (is_bool($value)) {
  2879. $value = var_export($value, true);
  2880. }
  2881. if (is_string($rawVal) && $rawVal != $value) {
  2882. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>', true, IOInterface::QUIET);
  2883. } else {
  2884. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>', true, IOInterface::QUIET);
  2885. }
  2886. }
  2887. }
  2888. }
  2889. <?php
  2890. namespace Composer\Command;
  2891. use Composer\Config;
  2892. use Composer\Factory;
  2893. use Composer\Installer;
  2894. use Composer\Installer\ProjectInstaller;
  2895. use Composer\Installer\SuggestedPackagesReporter;
  2896. use Composer\IO\IOInterface;
  2897. use Composer\Package\BasePackage;
  2898. use Composer\DependencyResolver\Operation\InstallOperation;
  2899. use Composer\Package\Version\VersionSelector;
  2900. use Composer\Package\AliasPackage;
  2901. use Composer\Repository\RepositoryFactory;
  2902. use Composer\Repository\CompositeRepository;
  2903. use Composer\Repository\PlatformRepository;
  2904. use Composer\Repository\InstalledArrayRepository;
  2905. use Composer\Repository\RepositorySet;
  2906. use Composer\Script\ScriptEvents;
  2907. use Composer\Util\Silencer;
  2908. use Symfony\Component\Console\Input\InputArgument;
  2909. use Symfony\Component\Console\Input\InputInterface;
  2910. use Symfony\Component\Console\Input\InputOption;
  2911. use Symfony\Component\Console\Output\OutputInterface;
  2912. use Symfony\Component\Finder\Finder;
  2913. use Composer\Json\JsonFile;
  2914. use Composer\Config\JsonConfigSource;
  2915. use Composer\Util\Filesystem;
  2916. use Composer\Util\Platform;
  2917. use Composer\Util\ProcessExecutor;
  2918. use Composer\Package\Version\VersionParser;
  2919. class CreateProjectCommand extends BaseCommand
  2920. {
  2921. protected $suggestedPackagesReporter;
  2922. protected function configure()
  2923. {
  2924. $this
  2925. ->setName('create-project')
  2926. ->setDescription('Creates new project from a package into given directory.')
  2927. ->setDefinition(array(
  2928. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed'),
  2929. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  2930. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  2931. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  2932. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  2933. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  2934. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  2935. 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'),
  2936. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  2937. 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.'),
  2938. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  2939. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  2940. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  2941. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  2942. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  2943. 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.'),
  2944. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  2945. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  2946. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  2947. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  2948. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  2949. new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
  2950. ))
  2951. ->setHelp(
  2952. <<<EOT
  2953. The <info>create-project</info> command creates a new project from a given
  2954. package into a new directory. If executed without params and in a directory
  2955. with a composer.json file it installs the packages for the current project.
  2956. You can use this command to bootstrap new projects or setup a clean
  2957. version-controlled installation for developers of your project.
  2958. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  2959. You can also specify the version with the package name using = or : as separator.
  2960. <info>php composer.phar create-project vendor/project:version target-directory</info>
  2961. To install unstable packages, either specify the version you want, or use the
  2962. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  2963. To setup a developer workable version you should create the project using the source
  2964. controlled code by appending the <info>'--prefer-source'</info> flag.
  2965. To install a package from another repository than the default one you
  2966. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  2967. Read more at https://getcomposer.org/doc/03-cli.md#create-project
  2968. EOT
  2969. )
  2970. ;
  2971. }
  2972. protected function execute(InputInterface $input, OutputInterface $output)
  2973. {
  2974. $config = Factory::createConfig();
  2975. $io = $this->getIO();
  2976. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input, true);
  2977. if ($input->getOption('dev')) {
  2978. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  2979. }
  2980. if ($input->getOption('no-custom-installers')) {
  2981. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  2982. $input->setOption('no-plugins', true);
  2983. }
  2984. if ($input->isInteractive() && $input->getOption('ask')) {
  2985. $parts = explode("/", strtolower($input->getArgument('package')), 2);
  2986. $input->setArgument('directory', $io->ask('New project directory [<comment>'.array_pop($parts).'</comment>]: '));
  2987. }
  2988. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  2989. return $this->installProject(
  2990. $io,
  2991. $config,
  2992. $input,
  2993. $input->getArgument('package'),
  2994. $input->getArgument('directory'),
  2995. $input->getArgument('version'),
  2996. $input->getOption('stability'),
  2997. $preferSource,
  2998. $preferDist,
  2999. !$input->getOption('no-dev'),
  3000. $input->getOption('repository') ?: $input->getOption('repository-url'),
  3001. $input->getOption('no-plugins'),
  3002. $input->getOption('no-scripts'),
  3003. $input->getOption('no-progress'),
  3004. $input->getOption('no-install'),
  3005. $ignorePlatformReqs,
  3006. !$input->getOption('no-secure-http'),
  3007. $input->getOption('add-repository')
  3008. );
  3009. }
  3010. public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName = null, $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)
  3011. {
  3012. $oldCwd = getcwd();
  3013. if ($repositories !== null && !is_array($repositories)) {
  3014. $repositories = (array) $repositories;
  3015. }
  3016. $io->loadConfiguration($config);
  3017. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  3018. if ($packageName !== null) {
  3019. $installedFromVcs = $this->installRootPackage($io, $config, $packageName, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repositories, $disablePlugins, $noScripts, $noProgress, $ignorePlatformReqs, $secureHttp);
  3020. } else {
  3021. $installedFromVcs = false;
  3022. }
  3023. if ($repositories !== null && $addRepository && is_file('composer.lock')) {
  3024. unlink('composer.lock');
  3025. }
  3026. $composer = Factory::create($io, null, $disablePlugins);
  3027. $composer->getEventDispatcher()->setRunScripts(!$noScripts);
  3028. if ($repositories !== null && $addRepository) {
  3029. foreach ($repositories as $index => $repo) {
  3030. $repoConfig = RepositoryFactory::configFromString($io, $composer->getConfig(), $repo, true);
  3031. $composerJsonRepositoriesConfig = $composer->getConfig()->getRepositories();
  3032. $name = RepositoryFactory::generateRepositoryName($index, $repoConfig, $composerJsonRepositoriesConfig);
  3033. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  3034. if (
  3035. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  3036. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  3037. ) {
  3038. $configSource->addRepository('packagist.org', false);
  3039. } else {
  3040. $configSource->addRepository($name, $repoConfig, false);
  3041. }
  3042. $composer = Factory::create($io, null, $disablePlugins);
  3043. }
  3044. }
  3045. $process = new ProcessExecutor($io);
  3046. $fs = new Filesystem($process);
  3047. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  3048. $config = $composer->getConfig();
  3049. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  3050. if ($noInstall === false) {
  3051. $composer->getInstallationManager()->setOutputProgress(!$noProgress);
  3052. $installer = Installer::create($io, $composer);
  3053. $installer->setPreferSource($preferSource)
  3054. ->setPreferDist($preferDist)
  3055. ->setDevMode($installDevPackages)
  3056. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  3057. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  3058. ->setOptimizeAutoloader($config->get('optimize-autoloader'))
  3059. ->setClassMapAuthoritative($config->get('classmap-authoritative'))
  3060. ->setApcuAutoloader($config->get('apcu-autoloader'));
  3061. if (!$composer->getLocker()->isLocked()) {
  3062. $installer->setUpdate(true);
  3063. }
  3064. if ($disablePlugins) {
  3065. $installer->disablePlugins();
  3066. }
  3067. $status = $installer->run();
  3068. if (0 !== $status) {
  3069. return $status;
  3070. }
  3071. }
  3072. $hasVcs = $installedFromVcs;
  3073. if (
  3074. !$input->getOption('keep-vcs')
  3075. && $installedFromVcs
  3076. && (
  3077. $input->getOption('remove-vcs')
  3078. || !$io->isInteractive()
  3079. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ')
  3080. )
  3081. ) {
  3082. $finder = new Finder();
  3083. $finder->depth(0)->directories()->in(getcwd())->ignoreVCS(false)->ignoreDotFiles(false);
  3084. foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
  3085. $finder->name($vcsName);
  3086. }
  3087. try {
  3088. $dirs = iterator_to_array($finder);
  3089. unset($finder);
  3090. foreach ($dirs as $dir) {
  3091. if (!$fs->removeDirectory($dir)) {
  3092. throw new \RuntimeException('Could not remove '.$dir);
  3093. }
  3094. }
  3095. } catch (\Exception $e) {
  3096. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  3097. }
  3098. $hasVcs = false;
  3099. }
  3100. if (!$hasVcs) {
  3101. $package = $composer->getPackage();
  3102. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  3103. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  3104. foreach ($package->{'get'.$meta['method']}() as $link) {
  3105. if ($link->getPrettyConstraint() === 'self.version') {
  3106. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  3107. }
  3108. }
  3109. }
  3110. }
  3111. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  3112. chdir($oldCwd);
  3113. $vendorComposerDir = $config->get('vendor-dir').'/composer';
  3114. if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
  3115. Silencer::call('rmdir', $vendorComposerDir);
  3116. $vendorDir = $config->get('vendor-dir');
  3117. if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
  3118. Silencer::call('rmdir', $vendorDir);
  3119. }
  3120. }
  3121. return 0;
  3122. }
  3123. 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)
  3124. {
  3125. if (!$secureHttp) {
  3126. $config->merge(array('config' => array('secure-http' => false)));
  3127. }
  3128. $parser = new VersionParser();
  3129. $requirements = $parser->parseNameVersionPairs(array($packageName));
  3130. $name = strtolower($requirements[0]['name']);
  3131. if (!$packageVersion && isset($requirements[0]['version'])) {
  3132. $packageVersion = $requirements[0]['version'];
  3133. }
  3134. if (null === $directory) {
  3135. $parts = explode("/", $name, 2);
  3136. $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  3137. }
  3138. $process = new ProcessExecutor($io);
  3139. $fs = new Filesystem($process);
  3140. if (!$fs->isAbsolutePath($directory)) {
  3141. $directory = getcwd() . DIRECTORY_SEPARATOR . $directory;
  3142. }
  3143. $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(getcwd(), $directory, true) . '"</info>');
  3144. if (file_exists($directory)) {
  3145. if (!is_dir($directory)) {
  3146. throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
  3147. }
  3148. if (!$fs->isDirEmpty($directory)) {
  3149. throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
  3150. }
  3151. }
  3152. if (null === $stability) {
  3153. if (null === $packageVersion) {
  3154. $stability = 'stable';
  3155. } elseif (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
  3156. $stability = $match[1];
  3157. } else {
  3158. $stability = VersionParser::parseStability($packageVersion);
  3159. }
  3160. }
  3161. $stability = VersionParser::normalizeStability($stability);
  3162. if (!isset(BasePackage::$stabilities[$stability])) {
  3163. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::$stabilities)));
  3164. }
  3165. $composer = Factory::create($io, $config->all(), $disablePlugins);
  3166. $config = $composer->getConfig();
  3167. $rm = $composer->getRepositoryManager();
  3168. $repositorySet = new RepositorySet($stability);
  3169. if (null === $repositories) {
  3170. $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));
  3171. } else {
  3172. foreach ($repositories as $repo) {
  3173. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  3174. if (
  3175. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  3176. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  3177. ) {
  3178. continue;
  3179. }
  3180. $repositorySet->addRepository(RepositoryFactory::createRepo($io, $config, $repoConfig, $rm));
  3181. }
  3182. }
  3183. $platformOverrides = $config->get('platform') ?: array();
  3184. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3185. $versionSelector = new VersionSelector($repositorySet, $platformRepo);
  3186. $package = $versionSelector->findBestCandidate($name, $packageVersion, $stability, $ignorePlatformReqs);
  3187. if (!$package) {
  3188. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  3189. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, $packageVersion, $stability, true)) {
  3190. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version, PHP extensions and Composer version.');
  3191. }
  3192. throw new \InvalidArgumentException($errorMessage .'.');
  3193. }
  3194. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  3195. @mkdir($directory, 0777, true);
  3196. if ($realDir = realpath($directory)) {
  3197. pcntl_async_signals(true);
  3198. pcntl_signal(SIGINT, function () use ($realDir) {
  3199. $fs = new Filesystem();
  3200. $fs->removeDirectory($realDir);
  3201. exit(130);
  3202. });
  3203. }
  3204. }
  3205. if (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli') {
  3206. @mkdir($directory, 0777, true);
  3207. if ($realDir = realpath($directory)) {
  3208. sapi_windows_set_ctrl_handler(function () use ($realDir) {
  3209. $fs = new Filesystem();
  3210. $fs->removeDirectory($realDir);
  3211. exit(130);
  3212. });
  3213. }
  3214. }
  3215. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  3216. $package = $package->getAliasOf();
  3217. }
  3218. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  3219. if ($disablePlugins) {
  3220. $io->writeError('<info>Plugins have been disabled.</info>');
  3221. }
  3222. if ($package instanceof AliasPackage) {
  3223. $package = $package->getAliasOf();
  3224. }
  3225. $dm = $composer->getDownloadManager();
  3226. $dm->setPreferSource($preferSource)
  3227. ->setPreferDist($preferDist);
  3228. $projectInstaller = new ProjectInstaller($directory, $dm, $fs);
  3229. $im = $composer->getInstallationManager();
  3230. $im->setOutputProgress(!$noProgress);
  3231. $im->addInstaller($projectInstaller);
  3232. $im->execute(new InstalledArrayRepository(), array(new InstallOperation($package)));
  3233. $im->notifyInstalls($io);
  3234. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  3235. $installedFromVcs = 'source' === $package->getInstallationSource();
  3236. $io->writeError('<info>Created project in ' . $directory . '</info>');
  3237. chdir($directory);
  3238. Platform::putEnv('COMPOSER_ROOT_VERSION', $package->getPrettyVersion());
  3239. return $installedFromVcs;
  3240. }
  3241. }
  3242. <?php
  3243. namespace Composer\Command;
  3244. use Symfony\Component\Console\Input\InputInterface;
  3245. use Symfony\Component\Console\Output\OutputInterface;
  3246. use Symfony\Component\Console\Input\InputArgument;
  3247. use Symfony\Component\Console\Input\InputOption;
  3248. class DependsCommand extends BaseDependencyCommand
  3249. {
  3250. protected function configure()
  3251. {
  3252. $this
  3253. ->setName('depends')
  3254. ->setAliases(array('why'))
  3255. ->setDescription('Shows which packages cause the given package to be installed.')
  3256. ->setDefinition(array(
  3257. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  3258. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  3259. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  3260. ))
  3261. ->setHelp(
  3262. <<<EOT
  3263. Displays detailed information about where a package is referenced.
  3264. <info>php composer.phar depends composer/composer</info>
  3265. Read more at https://getcomposer.org/doc/03-cli.md#depends-why-
  3266. EOT
  3267. )
  3268. ;
  3269. }
  3270. protected function execute(InputInterface $input, OutputInterface $output)
  3271. {
  3272. return parent::doExecute($input, $output);
  3273. }
  3274. }
  3275. <?php
  3276. namespace Composer\Command;
  3277. use Composer\Composer;
  3278. use Composer\Factory;
  3279. use Composer\Config;
  3280. use Composer\Downloader\TransportException;
  3281. use Composer\Repository\PlatformRepository;
  3282. use Composer\Plugin\CommandEvent;
  3283. use Composer\Plugin\PluginEvents;
  3284. use Composer\Util\ConfigValidator;
  3285. use Composer\Util\IniHelper;
  3286. use Composer\Util\ProcessExecutor;
  3287. use Composer\Util\HttpDownloader;
  3288. use Composer\Util\StreamContextFactory;
  3289. use Composer\Util\Platform;
  3290. use Composer\SelfUpdate\Keys;
  3291. use Composer\SelfUpdate\Versions;
  3292. use Composer\IO\NullIO;
  3293. use Composer\Package\CompletePackageInterface;
  3294. use Composer\XdebugHandler\XdebugHandler;
  3295. use Symfony\Component\Console\Input\InputInterface;
  3296. use Symfony\Component\Console\Output\OutputInterface;
  3297. use Symfony\Component\Process\ExecutableFinder;
  3298. class DiagnoseCommand extends BaseCommand
  3299. {
  3300. protected $httpDownloader;
  3301. protected $process;
  3302. protected $exitCode = 0;
  3303. protected function configure()
  3304. {
  3305. $this
  3306. ->setName('diagnose')
  3307. ->setDescription('Diagnoses the system to identify common errors.')
  3308. ->setHelp(
  3309. <<<EOT
  3310. The <info>diagnose</info> command checks common errors to help debugging problems.
  3311. The process exit code will be 1 in case of warnings and 2 for errors.
  3312. Read more at https://getcomposer.org/doc/03-cli.md#diagnose
  3313. EOT
  3314. )
  3315. ;
  3316. }
  3317. protected function execute(InputInterface $input, OutputInterface $output)
  3318. {
  3319. $composer = $this->getComposer(false);
  3320. $io = $this->getIO();
  3321. if ($composer) {
  3322. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  3323. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3324. $io->write('Checking composer.json: ', false);
  3325. $this->outputResult($this->checkComposerSchema());
  3326. }
  3327. if ($composer) {
  3328. $config = $composer->getConfig();
  3329. } else {
  3330. $config = Factory::createConfig();
  3331. }
  3332. $config->merge(array('config' => array('secure-http' => false)));
  3333. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  3334. $this->httpDownloader = Factory::createHttpDownloader($io, $config);
  3335. $this->process = new ProcessExecutor($io);
  3336. $io->write('Checking platform settings: ', false);
  3337. $this->outputResult($this->checkPlatform());
  3338. $io->write('Checking git settings: ', false);
  3339. $this->outputResult($this->checkGit());
  3340. $io->write('Checking http connectivity to packagist: ', false);
  3341. $this->outputResult($this->checkHttp('http', $config));
  3342. $io->write('Checking https connectivity to packagist: ', false);
  3343. $this->outputResult($this->checkHttp('https', $config));
  3344. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  3345. if (!empty($opts['http']['proxy'])) {
  3346. $io->write('Checking HTTP proxy: ', false);
  3347. $this->outputResult($this->checkHttpProxy());
  3348. }
  3349. if ($oauth = $config->get('github-oauth')) {
  3350. foreach ($oauth as $domain => $token) {
  3351. $io->write('Checking '.$domain.' oauth access: ', false);
  3352. $this->outputResult($this->checkGithubOauth($domain, $token));
  3353. }
  3354. } else {
  3355. $io->write('Checking github.com rate limit: ', false);
  3356. try {
  3357. $rate = $this->getGithubRateLimit('github.com');
  3358. if (!is_array($rate)) {
  3359. $this->outputResult($rate);
  3360. } elseif (10 > $rate['remaining']) {
  3361. $io->write('<warning>WARNING</warning>');
  3362. $io->write(sprintf(
  3363. '<comment>Github has a rate limit on their API. '
  3364. . 'You currently have <options=bold>%u</options=bold> '
  3365. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  3366. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  3367. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  3368. $rate['remaining'],
  3369. $rate['limit']
  3370. ));
  3371. } else {
  3372. $this->outputResult(true);
  3373. }
  3374. } catch (\Exception $e) {
  3375. if ($e instanceof TransportException && $e->getCode() === 401) {
  3376. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  3377. } else {
  3378. $this->outputResult($e);
  3379. }
  3380. }
  3381. }
  3382. $io->write('Checking disk free space: ', false);
  3383. $this->outputResult($this->checkDiskSpace($config));
  3384. if (strpos(__FILE__, 'phar:') === 0) {
  3385. $io->write('Checking pubkeys: ', false);
  3386. $this->outputResult($this->checkPubKeys($config));
  3387. $io->write('Checking composer version: ', false);
  3388. $this->outputResult($this->checkVersion($config));
  3389. }
  3390. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::getVersion()));
  3391. $platformOverrides = $config->get('platform') ?: array();
  3392. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3393. $phpPkg = $platformRepo->findPackage('php', '*');
  3394. $phpVersion = $phpPkg->getPrettyVersion();
  3395. if ($phpPkg instanceof CompletePackageInterface && false !== strpos($phpPkg->getDescription(), 'overridden')) {
  3396. $phpVersion .= ' - ' . $phpPkg->getDescription();
  3397. }
  3398. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  3399. if (defined('PHP_BINARY')) {
  3400. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  3401. }
  3402. $io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
  3403. $io->write('cURL version: ' . $this->getCurlVersion());
  3404. $finder = new ExecutableFinder;
  3405. $hasSystemUnzip = (bool) $finder->find('unzip');
  3406. $bin7zip = '';
  3407. if ($hasSystem7zip = (bool) $finder->find('7z', null, array('C:\Program Files\7-Zip'))) {
  3408. $bin7zip = '7z';
  3409. }
  3410. if (!Platform::isWindows() && !$hasSystem7zip && $hasSystem7zip = (bool) $finder->find('7zz')) {
  3411. $bin7zip = '7zz';
  3412. }
  3413. $io->write(
  3414. 'zip: ' . (extension_loaded('zip') ? '<comment>extension present</comment>' : '<comment>extension not loaded</comment>')
  3415. . ', ' . ($hasSystemUnzip ? '<comment>unzip present</comment>' : '<comment>unzip not available</comment>')
  3416. . ', ' . ($hasSystem7zip ? '<comment>7-Zip present ('.$bin7zip.')</comment>' : '<comment>7-Zip not available</comment>')
  3417. . (($hasSystem7zip || $hasSystemUnzip) && !function_exists('proc_open') ? ', <warning>proc_open is disabled or not present, unzip/7-z will not be usable</warning>' : '')
  3418. );
  3419. return $this->exitCode;
  3420. }
  3421. private function checkComposerSchema()
  3422. {
  3423. $validator = new ConfigValidator($this->getIO());
  3424. list($errors, , $warnings) = $validator->validate(Factory::getComposerFile());
  3425. if ($errors || $warnings) {
  3426. $messages = array(
  3427. 'error' => $errors,
  3428. 'warning' => $warnings,
  3429. );
  3430. $output = '';
  3431. foreach ($messages as $style => $msgs) {
  3432. foreach ($msgs as $msg) {
  3433. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  3434. }
  3435. }
  3436. return rtrim($output);
  3437. }
  3438. return true;
  3439. }
  3440. private function checkGit()
  3441. {
  3442. if (!function_exists('proc_open')) {
  3443. return '<comment>proc_open is not available, git cannot be used</comment>';
  3444. }
  3445. $this->process->execute('git config color.ui', $output);
  3446. if (strtolower(trim($output)) === 'always') {
  3447. 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>';
  3448. }
  3449. return true;
  3450. }
  3451. private function checkHttp($proto, Config $config)
  3452. {
  3453. $result = $this->checkConnectivity();
  3454. if ($result !== true) {
  3455. return $result;
  3456. }
  3457. $result = array();
  3458. if ($proto === 'https' && $config->get('disable-tls') === true) {
  3459. $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  3460. }
  3461. try {
  3462. $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
  3463. } catch (TransportException $e) {
  3464. if ($hints = HttpDownloader::getExceptionHints($e)) {
  3465. foreach ($hints as $hint) {
  3466. $result[] = $hint;
  3467. }
  3468. }
  3469. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  3470. }
  3471. if (isset($tlsWarning)) {
  3472. $result[] = $tlsWarning;
  3473. }
  3474. if (count($result) > 0) {
  3475. return $result;
  3476. }
  3477. return true;
  3478. }
  3479. private function checkHttpProxy()
  3480. {
  3481. $result = $this->checkConnectivity();
  3482. if ($result !== true) {
  3483. return $result;
  3484. }
  3485. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  3486. try {
  3487. $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();
  3488. $hash = reset($json['provider-includes']);
  3489. $hash = $hash['sha256'];
  3490. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  3491. $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();
  3492. if (hash('sha256', $provider) !== $hash) {
  3493. return 'It seems that your proxy is modifying http traffic on the fly';
  3494. }
  3495. } catch (\Exception $e) {
  3496. return $e;
  3497. }
  3498. return true;
  3499. }
  3500. private function checkGithubOauth($domain, $token)
  3501. {
  3502. $result = $this->checkConnectivity();
  3503. if ($result !== true) {
  3504. return $result;
  3505. }
  3506. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3507. try {
  3508. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  3509. $this->httpDownloader->get($url, array(
  3510. 'retry-auth-failure' => false,
  3511. ));
  3512. return true;
  3513. } catch (\Exception $e) {
  3514. if ($e instanceof TransportException && $e->getCode() === 401) {
  3515. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  3516. }
  3517. return $e;
  3518. }
  3519. }
  3520. private function getGithubRateLimit($domain, $token = null)
  3521. {
  3522. $result = $this->checkConnectivity();
  3523. if ($result !== true) {
  3524. return $result;
  3525. }
  3526. if ($token) {
  3527. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3528. }
  3529. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  3530. $data = $this->httpDownloader->get($url, array('retry-auth-failure' => false))->decodeJson();
  3531. return $data['resources']['core'];
  3532. }
  3533. private function checkDiskSpace(Config $config)
  3534. {
  3535. $minSpaceFree = 1024 * 1024;
  3536. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  3537. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  3538. ) {
  3539. return '<error>The disk hosting '.$dir.' is full</error>';
  3540. }
  3541. return true;
  3542. }
  3543. private function checkPubKeys(Config $config)
  3544. {
  3545. $home = $config->get('home');
  3546. $errors = array();
  3547. $io = $this->getIO();
  3548. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  3549. $io->write('');
  3550. }
  3551. if (file_exists($home.'/keys.tags.pub')) {
  3552. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  3553. } else {
  3554. $errors[] = '<error>Missing pubkey for tags verification</error>';
  3555. }
  3556. if (file_exists($home.'/keys.dev.pub')) {
  3557. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  3558. } else {
  3559. $errors[] = '<error>Missing pubkey for dev verification</error>';
  3560. }
  3561. if ($errors) {
  3562. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  3563. }
  3564. return $errors ?: true;
  3565. }
  3566. private function checkVersion(Config $config)
  3567. {
  3568. $result = $this->checkConnectivity();
  3569. if ($result !== true) {
  3570. return $result;
  3571. }
  3572. $versionsUtil = new Versions($config, $this->httpDownloader);
  3573. try {
  3574. $latest = $versionsUtil->getLatest();
  3575. } catch (\Exception $e) {
  3576. return $e;
  3577. }
  3578. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  3579. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  3580. }
  3581. return true;
  3582. }
  3583. private function getCurlVersion()
  3584. {
  3585. if (extension_loaded('curl')) {
  3586. if (!HttpDownloader::isCurlEnabled()) {
  3587. return '<error>disabled via disable_functions, using php streams fallback, which reduces performance</error>';
  3588. }
  3589. $version = curl_version();
  3590. return '<comment>'.$version['version'].'</comment> '.
  3591. 'libz <comment>'.(!empty($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
  3592. 'ssl <comment>'.(isset($version['ssl_version']) ? $version['ssl_version'] : 'missing').'</comment>';
  3593. }
  3594. return '<error>missing, using php streams fallback, which reduces performance</error>';
  3595. }
  3596. private function outputResult($result)
  3597. {
  3598. $io = $this->getIO();
  3599. if (true === $result) {
  3600. $io->write('<info>OK</info>');
  3601. return;
  3602. }
  3603. $hadError = false;
  3604. $hadWarning = false;
  3605. if ($result instanceof \Exception) {
  3606. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  3607. }
  3608. if (!$result) {
  3609. $hadError = true;
  3610. } else {
  3611. if (!is_array($result)) {
  3612. $result = array($result);
  3613. }
  3614. foreach ($result as $message) {
  3615. if (false !== strpos($message, '<error>')) {
  3616. $hadError = true;
  3617. } elseif (false !== strpos($message, '<warning>')) {
  3618. $hadWarning = true;
  3619. }
  3620. }
  3621. }
  3622. if ($hadError) {
  3623. $io->write('<error>FAIL</error>');
  3624. $this->exitCode = max($this->exitCode, 2);
  3625. } elseif ($hadWarning) {
  3626. $io->write('<warning>WARNING</warning>');
  3627. $this->exitCode = max($this->exitCode, 1);
  3628. }
  3629. if ($result) {
  3630. foreach ($result as $message) {
  3631. $io->write($message);
  3632. }
  3633. }
  3634. }
  3635. private function checkPlatform()
  3636. {
  3637. $output = '';
  3638. $out = function ($msg, $style) use (&$output) {
  3639. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  3640. };
  3641. $errors = array();
  3642. $warnings = array();
  3643. $displayIniMessage = false;
  3644. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  3645. $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.';
  3646. if (!function_exists('json_decode')) {
  3647. $errors['json'] = true;
  3648. }
  3649. if (!extension_loaded('Phar')) {
  3650. $errors['phar'] = true;
  3651. }
  3652. if (!extension_loaded('filter')) {
  3653. $errors['filter'] = true;
  3654. }
  3655. if (!extension_loaded('hash')) {
  3656. $errors['hash'] = true;
  3657. }
  3658. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  3659. $errors['iconv_mbstring'] = true;
  3660. }
  3661. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  3662. $errors['allow_url_fopen'] = true;
  3663. }
  3664. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  3665. $errors['ioncube'] = ioncube_loader_version();
  3666. }
  3667. if (PHP_VERSION_ID < 50302) {
  3668. $errors['php'] = PHP_VERSION;
  3669. }
  3670. if (!isset($errors['php']) && PHP_VERSION_ID < 50304) {
  3671. $warnings['php'] = PHP_VERSION;
  3672. }
  3673. if (!extension_loaded('openssl')) {
  3674. $errors['openssl'] = true;
  3675. }
  3676. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  3677. $warnings['openssl_version'] = true;
  3678. }
  3679. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  3680. $warnings['apc_cli'] = true;
  3681. }
  3682. if (!extension_loaded('zlib')) {
  3683. $warnings['zlib'] = true;
  3684. }
  3685. ob_start();
  3686. phpinfo(INFO_GENERAL);
  3687. $phpinfo = ob_get_clean();
  3688. if (preg_match('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  3689. $configure = $match[1];
  3690. if (false !== strpos($configure, '--enable-sigchild')) {
  3691. $warnings['sigchild'] = true;
  3692. }
  3693. if (false !== strpos($configure, '--with-curlwrappers')) {
  3694. $warnings['curlwrappers'] = true;
  3695. }
  3696. }
  3697. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  3698. $warnings['xdebug_profile'] = true;
  3699. } elseif (XdebugHandler::isXdebugActive()) {
  3700. $warnings['xdebug_loaded'] = true;
  3701. }
  3702. if (defined('PHP_WINDOWS_VERSION_BUILD')
  3703. && (version_compare(PHP_VERSION, '7.2.23', '<')
  3704. || (version_compare(PHP_VERSION, '7.3.0', '>=')
  3705. && version_compare(PHP_VERSION, '7.3.10', '<')))) {
  3706. $warnings['onedrive'] = PHP_VERSION;
  3707. }
  3708. if (!empty($errors)) {
  3709. foreach ($errors as $error => $current) {
  3710. switch ($error) {
  3711. case 'json':
  3712. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  3713. $text .= "Install it or recompile php without --disable-json";
  3714. break;
  3715. case 'phar':
  3716. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  3717. $text .= "Install it or recompile php without --disable-phar";
  3718. break;
  3719. case 'filter':
  3720. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  3721. $text .= "Install it or recompile php without --disable-filter";
  3722. break;
  3723. case 'hash':
  3724. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  3725. $text .= "Install it or recompile php without --disable-hash";
  3726. break;
  3727. case 'iconv_mbstring':
  3728. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  3729. $text .= "Install either of them or recompile php without --disable-iconv";
  3730. break;
  3731. case 'php':
  3732. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 5.3.2 or higher.";
  3733. break;
  3734. case 'allow_url_fopen':
  3735. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  3736. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3737. $text .= " allow_url_fopen = On";
  3738. $displayIniMessage = true;
  3739. break;
  3740. case 'ioncube':
  3741. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  3742. $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;
  3743. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  3744. $displayIniMessage = true;
  3745. break;
  3746. case 'openssl':
  3747. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  3748. $text .= "If possible you should enable it or recompile php with --with-openssl";
  3749. break;
  3750. default:
  3751. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $error));
  3752. }
  3753. $out($text, 'error');
  3754. }
  3755. $output .= PHP_EOL;
  3756. }
  3757. if (!empty($warnings)) {
  3758. foreach ($warnings as $warning => $current) {
  3759. switch ($warning) {
  3760. case 'apc_cli':
  3761. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  3762. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3763. $text .= " apc.enable_cli = Off";
  3764. $displayIniMessage = true;
  3765. break;
  3766. case 'zlib':
  3767. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  3768. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  3769. $displayIniMessage = true;
  3770. break;
  3771. case 'sigchild':
  3772. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  3773. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  3774. $text .= " https://bugs.php.net/bug.php?id=22999";
  3775. break;
  3776. case 'curlwrappers':
  3777. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  3778. $text .= " Recompile it without this flag if possible";
  3779. break;
  3780. case 'php':
  3781. $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
  3782. $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
  3783. break;
  3784. case 'openssl_version':
  3785. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  3786. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  3787. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  3788. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  3789. break;
  3790. case 'xdebug_loaded':
  3791. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  3792. $text .= " Disabling it when using Composer is recommended.";
  3793. break;
  3794. case 'xdebug_profile':
  3795. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  3796. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  3797. $text .= " xdebug.profiler_enabled = 0";
  3798. $displayIniMessage = true;
  3799. break;
  3800. case 'onedrive':
  3801. $text = "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.".PHP_EOL;
  3802. $text .= "Upgrade your PHP ({$current}) to use this location with Composer.".PHP_EOL;
  3803. break;
  3804. default:
  3805. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $warning));
  3806. }
  3807. $out($text, 'comment');
  3808. }
  3809. }
  3810. if ($displayIniMessage) {
  3811. $out($iniMessage, 'comment');
  3812. }
  3813. return !$warnings && !$errors ? true : $output;
  3814. }
  3815. private function checkConnectivity()
  3816. {
  3817. if (!ini_get('allow_url_fopen')) {
  3818. return '<info>Skipped because allow_url_fopen is missing.</info>';
  3819. }
  3820. return true;
  3821. }
  3822. }
  3823. <?php
  3824. namespace Composer\Command;
  3825. use Composer\Plugin\CommandEvent;
  3826. use Composer\Plugin\PluginEvents;
  3827. use Symfony\Component\Console\Input\InputInterface;
  3828. use Symfony\Component\Console\Input\InputOption;
  3829. use Symfony\Component\Console\Output\OutputInterface;
  3830. class DumpAutoloadCommand extends BaseCommand
  3831. {
  3832. protected function configure()
  3833. {
  3834. $this
  3835. ->setName('dump-autoload')
  3836. ->setAliases(array('dumpautoload'))
  3837. ->setDescription('Dumps the autoloader.')
  3838. ->setDefinition(array(
  3839. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  3840. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  3841. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  3842. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  3843. new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
  3844. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.'),
  3845. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.'),
  3846. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3847. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3848. ))
  3849. ->setHelp(
  3850. <<<EOT
  3851. <info>php composer.phar dump-autoload</info>
  3852. Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
  3853. EOT
  3854. )
  3855. ;
  3856. }
  3857. protected function execute(InputInterface $input, OutputInterface $output)
  3858. {
  3859. $composer = $this->getComposer();
  3860. $composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
  3861. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  3862. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3863. $installationManager = $composer->getInstallationManager();
  3864. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  3865. $package = $composer->getPackage();
  3866. $config = $composer->getConfig();
  3867. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  3868. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  3869. $apcuPrefix = $input->getOption('apcu-prefix');
  3870. $apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
  3871. if ($authoritative) {
  3872. $this->getIO()->write('<info>Generating optimized autoload files (authoritative)</info>');
  3873. } elseif ($optimize) {
  3874. $this->getIO()->write('<info>Generating optimized autoload files</info>');
  3875. } else {
  3876. $this->getIO()->write('<info>Generating autoload files</info>');
  3877. }
  3878. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  3879. $generator = $composer->getAutoloadGenerator();
  3880. if ($input->getOption('no-dev')) {
  3881. $generator->setDevMode(false);
  3882. }
  3883. if ($input->getOption('dev')) {
  3884. if ($input->getOption('no-dev')) {
  3885. throw new \InvalidArgumentException('You can not use both --no-dev and --dev as they conflict with each other.');
  3886. }
  3887. $generator->setDevMode(true);
  3888. }
  3889. $generator->setClassMapAuthoritative($authoritative);
  3890. $generator->setRunScripts(true);
  3891. $generator->setApcu($apcu, $apcuPrefix);
  3892. $generator->setIgnorePlatformRequirements($ignorePlatformReqs);
  3893. $numberOfClasses = $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  3894. if ($authoritative) {
  3895. $this->getIO()->write('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  3896. } elseif ($optimize) {
  3897. $this->getIO()->write('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  3898. } else {
  3899. $this->getIO()->write('<info>Generated autoload files</info>');
  3900. }
  3901. return 0;
  3902. }
  3903. }
  3904. <?php
  3905. namespace Composer\Command;
  3906. use Symfony\Component\Console\Input\InputInterface;
  3907. use Symfony\Component\Console\Input\InputOption;
  3908. use Symfony\Component\Console\Output\OutputInterface;
  3909. use Symfony\Component\Console\Input\InputArgument;
  3910. class ExecCommand extends BaseCommand
  3911. {
  3912. protected function configure()
  3913. {
  3914. $this
  3915. ->setName('exec')
  3916. ->setDescription('Executes a vendored binary/script.')
  3917. ->setDefinition(array(
  3918. new InputOption('list', 'l', InputOption::VALUE_NONE),
  3919. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit'),
  3920. new InputArgument(
  3921. 'args',
  3922. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  3923. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  3924. ),
  3925. ))
  3926. ->setHelp(
  3927. <<<EOT
  3928. Executes a vendored binary/script.
  3929. Read more at https://getcomposer.org/doc/03-cli.md#exec
  3930. EOT
  3931. )
  3932. ;
  3933. }
  3934. protected function execute(InputInterface $input, OutputInterface $output)
  3935. {
  3936. $composer = $this->getComposer();
  3937. $binDir = $composer->getConfig()->get('bin-dir');
  3938. if ($input->getOption('list') || !$input->getArgument('binary')) {
  3939. $bins = glob($binDir . '/*');
  3940. $bins = array_merge($bins, array_map(function ($e) {
  3941. return "$e (local)";
  3942. }, $composer->getPackage()->getBinaries()));
  3943. if (!$bins) {
  3944. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  3945. }
  3946. $this->getIO()->write(
  3947. <<<EOT
  3948. <comment>Available binaries:</comment>
  3949. EOT
  3950. );
  3951. foreach ($bins as $bin) {
  3952. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  3953. continue;
  3954. }
  3955. $previousBin = $bin;
  3956. $bin = basename($bin);
  3957. $this->getIO()->write(
  3958. <<<EOT
  3959. <info>- $bin</info>
  3960. EOT
  3961. );
  3962. }
  3963. return 0;
  3964. }
  3965. $binary = $input->getArgument('binary');
  3966. $dispatcher = $composer->getEventDispatcher();
  3967. $dispatcher->addListener('__exec_command', $binary);
  3968. if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory()) {
  3969. try {
  3970. chdir($this->getApplication()->getInitialWorkingDirectory());
  3971. } catch (\Exception $e) {
  3972. throw new \RuntimeException('Could not switch back to working directory "'.$this->getApplication()->getInitialWorkingDirectory().'"', 0, $e);
  3973. }
  3974. }
  3975. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  3976. }
  3977. }
  3978. <?php
  3979. namespace Composer\Command;
  3980. use Composer\Json\JsonFile;
  3981. use Composer\Package\AliasPackage;
  3982. use Composer\Package\BasePackage;
  3983. use Composer\Package\CompletePackageInterface;
  3984. use Composer\Repository\CompositeRepository;
  3985. use Composer\Semver\Constraint\MatchAllConstraint;
  3986. use Symfony\Component\Console\Input\InputInterface;
  3987. use Symfony\Component\Console\Input\InputOption;
  3988. use Symfony\Component\Console\Output\OutputInterface;
  3989. class FundCommand extends BaseCommand
  3990. {
  3991. protected function configure()
  3992. {
  3993. $this->setName('fund')
  3994. ->setDescription('Discover how to help fund the maintenance of your dependencies.')
  3995. ->setDefinition(array(
  3996. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  3997. ))
  3998. ;
  3999. }
  4000. protected function execute(InputInterface $input, OutputInterface $output)
  4001. {
  4002. $composer = $this->getComposer();
  4003. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4004. $remoteRepos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  4005. $fundings = array();
  4006. $packagesToLoad = array();
  4007. foreach ($repo->getPackages() as $package) {
  4008. if ($package instanceof AliasPackage) {
  4009. continue;
  4010. }
  4011. $packagesToLoad[$package->getName()] = new MatchAllConstraint();
  4012. }
  4013. $result = $remoteRepos->loadPackages($packagesToLoad, array('dev' => BasePackage::STABILITY_DEV), array());
  4014. foreach ($result['packages'] as $package) {
  4015. if (
  4016. !$package instanceof AliasPackage
  4017. && $package instanceof CompletePackageInterface
  4018. && $package->isDefaultBranch()
  4019. && $package->getFunding()
  4020. && isset($packagesToLoad[$package->getName()])
  4021. ) {
  4022. $fundings = $this->insertFundingData($fundings, $package);
  4023. unset($packagesToLoad[$package->getName()]);
  4024. }
  4025. }
  4026. foreach ($repo->getPackages() as $package) {
  4027. if ($package instanceof AliasPackage || !isset($packagesToLoad[$package->getName()])) {
  4028. continue;
  4029. }
  4030. if ($package instanceof CompletePackageInterface && $package->getFunding()) {
  4031. $fundings = $this->insertFundingData($fundings, $package);
  4032. }
  4033. }
  4034. ksort($fundings);
  4035. $io = $this->getIO();
  4036. $format = $input->getOption('format');
  4037. if (!in_array($format, array('text', 'json'))) {
  4038. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  4039. return 1;
  4040. }
  4041. if ($fundings && $format === 'text') {
  4042. $prev = null;
  4043. $io->write('The following packages were found in your dependencies which publish funding information:');
  4044. foreach ($fundings as $vendor => $links) {
  4045. $io->write('');
  4046. $io->write(sprintf("<comment>%s</comment>", $vendor));
  4047. foreach ($links as $url => $packages) {
  4048. $line = sprintf(' <info>%s</info>', implode(', ', $packages));
  4049. if ($prev !== $line) {
  4050. $io->write($line);
  4051. $prev = $line;
  4052. }
  4053. $io->write(sprintf(' %s', $url));
  4054. }
  4055. }
  4056. $io->write("");
  4057. $io->write("Please consider following these links and sponsoring the work of package authors!");
  4058. $io->write("Thank you!");
  4059. } elseif ($format === 'json') {
  4060. $io->write(JsonFile::encode($fundings));
  4061. } else {
  4062. $io->write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!");
  4063. }
  4064. return 0;
  4065. }
  4066. private function insertFundingData(array $fundings, CompletePackageInterface $package)
  4067. {
  4068. foreach ($package->getFunding() as $fundingOption) {
  4069. list($vendor, $packageName) = explode('/', $package->getPrettyName());
  4070. if (empty($fundingOption['url'])) {
  4071. continue;
  4072. }
  4073. $url = $fundingOption['url'];
  4074. if (!empty($fundingOption['type']) && $fundingOption['type'] === 'github' && preg_match('{^https://github.com/([^/]+)$}', $url, $match)) {
  4075. $url = 'https://github.com/sponsors/'.$match[1];
  4076. }
  4077. $fundings[$vendor][$url][] = $packageName;
  4078. }
  4079. return $fundings;
  4080. }
  4081. }
  4082. <?php
  4083. namespace Composer\Command;
  4084. use Composer\Factory;
  4085. use Composer\Util\Filesystem;
  4086. use Composer\Util\Platform;
  4087. use Symfony\Component\Console\Input\InputInterface;
  4088. use Symfony\Component\Console\Input\InputArgument;
  4089. use Symfony\Component\Console\Input\StringInput;
  4090. use Symfony\Component\Console\Output\OutputInterface;
  4091. class GlobalCommand extends BaseCommand
  4092. {
  4093. protected function configure()
  4094. {
  4095. $this
  4096. ->setName('global')
  4097. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME).')
  4098. ->setDefinition(array(
  4099. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  4100. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  4101. ))
  4102. ->setHelp(
  4103. <<<EOT
  4104. Use this command as a wrapper to run other Composer commands
  4105. within the global context of COMPOSER_HOME.
  4106. You can use this to install CLI utilities globally, all you need
  4107. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  4108. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  4109. and /home/<user>/.composer on unix systems.
  4110. If your system uses freedesktop.org standards, then it will first check
  4111. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  4112. Note: This path may vary depending on customizations to bin-dir in
  4113. composer.json or the environmental variable COMPOSER_BIN_DIR.
  4114. Read more at https://getcomposer.org/doc/03-cli.md#global
  4115. EOT
  4116. )
  4117. ;
  4118. }
  4119. public function run(InputInterface $input, OutputInterface $output)
  4120. {
  4121. if (!method_exists($input, '__toString')) {
  4122. throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
  4123. }
  4124. $tokens = preg_split('{\s+}', $input->__toString());
  4125. $args = array();
  4126. foreach ($tokens as $token) {
  4127. if ($token && $token[0] !== '-') {
  4128. $args[] = $token;
  4129. if (count($args) >= 2) {
  4130. break;
  4131. }
  4132. }
  4133. }
  4134. if (count($args) < 2) {
  4135. return parent::run($input, $output);
  4136. }
  4137. if (getenv('COMPOSER')) {
  4138. Platform::clearEnv('COMPOSER');
  4139. }
  4140. $config = Factory::createConfig();
  4141. $home = $config->get('home');
  4142. if (!is_dir($home)) {
  4143. $fs = new Filesystem();
  4144. $fs->ensureDirectoryExists($home);
  4145. if (!is_dir($home)) {
  4146. throw new \RuntimeException('Could not create home directory');
  4147. }
  4148. }
  4149. try {
  4150. chdir($home);
  4151. } catch (\Exception $e) {
  4152. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  4153. }
  4154. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  4155. $input = new StringInput(preg_replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  4156. $this->getApplication()->resetComposer();
  4157. return $this->getApplication()->run($input, $output);
  4158. }
  4159. public function isProxyCommand()
  4160. {
  4161. return true;
  4162. }
  4163. }
  4164. <?php
  4165. namespace Composer\Command;
  4166. use Composer\Package\CompletePackageInterface;
  4167. use Composer\Repository\RepositoryInterface;
  4168. use Composer\Repository\RootPackageRepository;
  4169. use Composer\Repository\RepositoryFactory;
  4170. use Composer\Util\Platform;
  4171. use Composer\Util\ProcessExecutor;
  4172. use Symfony\Component\Console\Input\InputArgument;
  4173. use Symfony\Component\Console\Input\InputOption;
  4174. use Symfony\Component\Console\Input\InputInterface;
  4175. use Symfony\Component\Console\Output\OutputInterface;
  4176. class HomeCommand extends BaseCommand
  4177. {
  4178. protected function configure()
  4179. {
  4180. $this
  4181. ->setName('browse')
  4182. ->setAliases(array('home'))
  4183. ->setDescription('Opens the package\'s repository URL or homepage in your browser.')
  4184. ->setDefinition(array(
  4185. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.'),
  4186. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  4187. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  4188. ))
  4189. ->setHelp(
  4190. <<<EOT
  4191. The home command opens or shows a package's repository URL or
  4192. homepage in your default browser.
  4193. To open the homepage by default, use -H or --homepage.
  4194. To show instead of open the repository or homepage URL, use -s or --show.
  4195. Read more at https://getcomposer.org/doc/03-cli.md#browse-home
  4196. EOT
  4197. );
  4198. }
  4199. protected function execute(InputInterface $input, OutputInterface $output)
  4200. {
  4201. $repos = $this->initializeRepos();
  4202. $io = $this->getIO();
  4203. $return = 0;
  4204. $packages = $input->getArgument('packages');
  4205. if (!$packages) {
  4206. $io->writeError('No package specified, opening homepage for the root package');
  4207. $packages = array($this->getComposer()->getPackage()->getName());
  4208. }
  4209. foreach ($packages as $packageName) {
  4210. $handled = false;
  4211. $packageExists = false;
  4212. foreach ($repos as $repo) {
  4213. foreach ($repo->findPackages($packageName) as $package) {
  4214. $packageExists = true;
  4215. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  4216. $handled = true;
  4217. break 2;
  4218. }
  4219. }
  4220. }
  4221. if (!$packageExists) {
  4222. $return = 1;
  4223. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  4224. }
  4225. if (!$handled) {
  4226. $return = 1;
  4227. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  4228. }
  4229. }
  4230. return $return;
  4231. }
  4232. private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
  4233. {
  4234. $support = $package->getSupport();
  4235. $url = isset($support['source']) ? $support['source'] : $package->getSourceUrl();
  4236. if (!$url || $showHomepage) {
  4237. $url = $package->getHomepage();
  4238. }
  4239. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  4240. return false;
  4241. }
  4242. if ($showOnly) {
  4243. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  4244. } else {
  4245. $this->openBrowser($url);
  4246. }
  4247. return true;
  4248. }
  4249. private function openBrowser($url)
  4250. {
  4251. $url = ProcessExecutor::escape($url);
  4252. $process = new ProcessExecutor($this->getIO());
  4253. if (Platform::isWindows()) {
  4254. $process->execute('start "web" explorer ' . $url, $output);
  4255. return;
  4256. }
  4257. $linux = $process->execute('which xdg-open', $output);
  4258. $osx = $process->execute('which open', $output);
  4259. if (0 === $linux) {
  4260. $process->execute('xdg-open ' . $url, $output);
  4261. } elseif (0 === $osx) {
  4262. $process->execute('open ' . $url, $output);
  4263. } else {
  4264. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  4265. }
  4266. }
  4267. private function initializeRepos()
  4268. {
  4269. $composer = $this->getComposer(false);
  4270. if ($composer) {
  4271. return array_merge(
  4272. array(new RootPackageRepository($composer->getPackage())),
  4273. array($composer->getRepositoryManager()->getLocalRepository()),
  4274. $composer->getRepositoryManager()->getRepositories()
  4275. );
  4276. }
  4277. return RepositoryFactory::defaultRepos($this->getIO());
  4278. }
  4279. }
  4280. <?php
  4281. namespace Composer\Command;
  4282. use Composer\Factory;
  4283. use Composer\Json\JsonFile;
  4284. use Composer\Json\JsonValidationException;
  4285. use Composer\Package\BasePackage;
  4286. use Composer\Package\CompletePackageInterface;
  4287. use Composer\Package\Package;
  4288. use Composer\Package\PackageInterface;
  4289. use Composer\Package\Version\VersionParser;
  4290. use Composer\Package\Version\VersionSelector;
  4291. use Composer\Repository\CompositeRepository;
  4292. use Composer\Repository\PlatformRepository;
  4293. use Composer\Repository\RepositoryFactory;
  4294. use Composer\Repository\RepositorySet;
  4295. use Composer\Util\Filesystem;
  4296. use Composer\Util\ProcessExecutor;
  4297. use Composer\Semver\Constraint\Constraint;
  4298. use Composer\Util\Silencer;
  4299. use Symfony\Component\Console\Input\ArrayInput;
  4300. use Symfony\Component\Console\Input\InputInterface;
  4301. use Symfony\Component\Console\Input\InputOption;
  4302. use Symfony\Component\Console\Output\OutputInterface;
  4303. use Symfony\Component\Process\ExecutableFinder;
  4304. use Symfony\Component\Process\Process;
  4305. use Symfony\Component\Console\Helper\FormatterHelper;
  4306. class InitCommand extends BaseCommand
  4307. {
  4308. protected $repos;
  4309. private $gitConfig;
  4310. private $repositorySets;
  4311. protected function configure()
  4312. {
  4313. $this
  4314. ->setName('init')
  4315. ->setDescription('Creates a basic composer.json file in current directory.')
  4316. ->setDefinition(array(
  4317. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  4318. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  4319. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  4320. new InputOption('type', null, InputOption::VALUE_OPTIONAL, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  4321. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  4322. 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"'),
  4323. 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"'),
  4324. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
  4325. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  4326. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  4327. new InputOption('autoload', 'a', InputOption::VALUE_REQUIRED, 'Add PSR-4 autoload mapping. Maps your package\'s namespace to the provided directory. (Expects a relative path, e.g. src/)'),
  4328. ))
  4329. ->setHelp(
  4330. <<<EOT
  4331. The <info>init</info> command creates a basic composer.json file
  4332. in the current directory.
  4333. <info>php composer.phar init</info>
  4334. Read more at https://getcomposer.org/doc/03-cli.md#init
  4335. EOT
  4336. )
  4337. ;
  4338. }
  4339. protected function execute(InputInterface $input, OutputInterface $output)
  4340. {
  4341. $io = $this->getIO();
  4342. $allowlist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license', 'autoload');
  4343. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)));
  4344. if (isset($options['name']) && !preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $options['name'])) {
  4345. throw new \InvalidArgumentException(
  4346. 'The package name '.$options['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_.-]+'
  4347. );
  4348. }
  4349. if (isset($options['author'])) {
  4350. $options['authors'] = $this->formatAuthors($options['author']);
  4351. unset($options['author']);
  4352. }
  4353. $repositories = $input->getOption('repository');
  4354. if ($repositories) {
  4355. $config = Factory::createConfig($io);
  4356. foreach ($repositories as $repo) {
  4357. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo, true);
  4358. }
  4359. }
  4360. if (isset($options['stability'])) {
  4361. $options['minimum-stability'] = $options['stability'];
  4362. unset($options['stability']);
  4363. }
  4364. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  4365. if (array() === $options['require']) {
  4366. $options['require'] = new \stdClass;
  4367. }
  4368. if (isset($options['require-dev'])) {
  4369. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  4370. if (array() === $options['require-dev']) {
  4371. $options['require-dev'] = new \stdClass;
  4372. }
  4373. }
  4374. $autoloadPath = null;
  4375. if (isset($options['autoload'])) {
  4376. $autoloadPath = $options['autoload'];
  4377. $namespace = $this->namespaceFromPackageName($input->getOption('name'));
  4378. $options['autoload'] = (object) array(
  4379. 'psr-4' => array(
  4380. $namespace . '\\' => $autoloadPath,
  4381. ),
  4382. );
  4383. }
  4384. $file = new JsonFile(Factory::getComposerFile());
  4385. $json = JsonFile::encode($options);
  4386. if ($input->isInteractive()) {
  4387. $io->writeError(array('', $json, ''));
  4388. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ')) {
  4389. $io->writeError('<error>Command aborted</error>');
  4390. return 1;
  4391. }
  4392. } else {
  4393. if (json_encode($options) === '{"require":{}}') {
  4394. throw new \RuntimeException('You have to run this command in interactive mode, or specify at least some data using --name, --require, etc.');
  4395. }
  4396. $io->writeError('Writing '.$file->getPath());
  4397. }
  4398. $file->write($options);
  4399. try {
  4400. $file->validateSchema(JsonFile::LAX_SCHEMA);
  4401. } catch (JsonValidationException $e) {
  4402. $io->writeError('<error>Schema validation error, aborting</error>');
  4403. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  4404. $io->writeError($e->getMessage() . ':' . PHP_EOL . $errors);
  4405. Silencer::call('unlink', $file->getPath());
  4406. return 1;
  4407. }
  4408. if ($autoloadPath) {
  4409. $filesystem = new Filesystem();
  4410. $filesystem->ensureDirectoryExists($autoloadPath);
  4411. if (!$this->hasDependencies($options)) {
  4412. $this->runDumpAutoloadCommand($output);
  4413. }
  4414. }
  4415. if ($input->isInteractive() && is_dir('.git')) {
  4416. $ignoreFile = realpath('.gitignore');
  4417. if (false === $ignoreFile) {
  4418. $ignoreFile = realpath('.') . '/.gitignore';
  4419. }
  4420. if (!$this->hasVendorIgnore($ignoreFile)) {
  4421. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  4422. if ($io->askConfirmation($question)) {
  4423. $this->addVendorIgnore($ignoreFile);
  4424. }
  4425. }
  4426. }
  4427. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  4428. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
  4429. $this->updateDependencies($output);
  4430. }
  4431. if ($autoloadPath) {
  4432. $namespace = $this->namespaceFromPackageName($input->getOption('name'));
  4433. $io->writeError('PSR-4 autoloading configured. Use "<comment>namespace '.$namespace.';</comment>" in '.$autoloadPath);
  4434. $io->writeError('Include the Composer autoloader with: <comment>require \'vendor/autoload.php\';</comment>');
  4435. }
  4436. return 0;
  4437. }
  4438. protected function interact(InputInterface $input, OutputInterface $output)
  4439. {
  4440. $git = $this->getGitConfig();
  4441. $io = $this->getIO();
  4442. $formatter = $this->getHelperSet()->get('formatter');
  4443. $repositories = $input->getOption('repository');
  4444. if ($repositories) {
  4445. $config = Factory::createConfig($io);
  4446. $repos = array(new PlatformRepository);
  4447. $createDefaultPackagistRepo = true;
  4448. foreach ($repositories as $repo) {
  4449. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  4450. if (
  4451. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  4452. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  4453. ) {
  4454. $createDefaultPackagistRepo = false;
  4455. continue;
  4456. }
  4457. $repos[] = RepositoryFactory::createRepo($io, $config, $repoConfig);
  4458. }
  4459. if ($createDefaultPackagistRepo) {
  4460. $repos[] = RepositoryFactory::createRepo($io, $config, array(
  4461. 'type' => 'composer',
  4462. 'url' => 'https://repo.packagist.org',
  4463. ));
  4464. }
  4465. $this->repos = new CompositeRepository($repos);
  4466. unset($repos, $config, $repositories);
  4467. }
  4468. $io->writeError(array(
  4469. '',
  4470. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  4471. '',
  4472. ));
  4473. $io->writeError(array(
  4474. '',
  4475. 'This command will guide you through creating your composer.json config.',
  4476. '',
  4477. ));
  4478. $cwd = realpath(".");
  4479. if (!$name = $input->getOption('name')) {
  4480. $name = basename($cwd);
  4481. $name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  4482. $name = strtolower($name);
  4483. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  4484. $name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
  4485. } elseif (isset($git['github.user'])) {
  4486. $name = $git['github.user'] . '/' . $name;
  4487. } elseif (!empty($_SERVER['USERNAME'])) {
  4488. $name = $_SERVER['USERNAME'] . '/' . $name;
  4489. } elseif (!empty($_SERVER['USER'])) {
  4490. $name = $_SERVER['USER'] . '/' . $name;
  4491. } elseif (get_current_user()) {
  4492. $name = get_current_user() . '/' . $name;
  4493. } else {
  4494. $name .= '/' . $name;
  4495. }
  4496. $name = strtolower($name);
  4497. }
  4498. $name = $io->askAndValidate(
  4499. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  4500. function ($value) use ($name) {
  4501. if (null === $value) {
  4502. return $name;
  4503. }
  4504. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) {
  4505. throw new \InvalidArgumentException(
  4506. '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_.-]+'
  4507. );
  4508. }
  4509. return $value;
  4510. },
  4511. null,
  4512. $name
  4513. );
  4514. $input->setOption('name', $name);
  4515. $description = $input->getOption('description') ?: false;
  4516. $description = $io->ask(
  4517. 'Description [<comment>'.$description.'</comment>]: ',
  4518. $description
  4519. );
  4520. $input->setOption('description', $description);
  4521. if (null === $author = $input->getOption('author')) {
  4522. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  4523. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  4524. } elseif (isset($git['user.name'])) {
  4525. $author_name = $git['user.name'];
  4526. }
  4527. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  4528. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  4529. } elseif (isset($git['user.email'])) {
  4530. $author_email = $git['user.email'];
  4531. }
  4532. if (isset($author_name, $author_email)) {
  4533. $author = sprintf('%s <%s>', $author_name, $author_email);
  4534. }
  4535. }
  4536. $self = $this;
  4537. $author = $io->askAndValidate(
  4538. 'Author [<comment>'.$author.'</comment>, n to skip]: ',
  4539. function ($value) use ($self, $author) {
  4540. if ($value === 'n' || $value === 'no') {
  4541. return;
  4542. }
  4543. $value = $value ?: $author;
  4544. $author = $self->parseAuthorString($value);
  4545. return sprintf('%s <%s>', $author['name'], $author['email']);
  4546. },
  4547. null,
  4548. $author
  4549. );
  4550. $input->setOption('author', $author);
  4551. $minimumStability = $input->getOption('stability') ?: null;
  4552. $minimumStability = $io->askAndValidate(
  4553. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  4554. function ($value) use ($minimumStability) {
  4555. if (null === $value) {
  4556. return $minimumStability;
  4557. }
  4558. if (!isset(BasePackage::$stabilities[$value])) {
  4559. throw new \InvalidArgumentException(
  4560. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  4561. implode(', ', array_keys(BasePackage::$stabilities))
  4562. );
  4563. }
  4564. return $value;
  4565. },
  4566. null,
  4567. $minimumStability
  4568. );
  4569. $input->setOption('stability', $minimumStability);
  4570. $type = $input->getOption('type') ?: false;
  4571. $type = $io->ask(
  4572. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  4573. $type
  4574. );
  4575. $input->setOption('type', $type);
  4576. if (null === $license = $input->getOption('license')) {
  4577. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  4578. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  4579. }
  4580. }
  4581. $license = $io->ask(
  4582. 'License [<comment>'.$license.'</comment>]: ',
  4583. $license
  4584. );
  4585. $input->setOption('license', $license);
  4586. $io->writeError(array('', 'Define your dependencies.', ''));
  4587. $repos = $this->getRepos();
  4588. $preferredStability = $minimumStability ?: 'stable';
  4589. $platformRepo = null;
  4590. if ($repos instanceof CompositeRepository) {
  4591. foreach ($repos->getRepositories() as $candidateRepo) {
  4592. if ($candidateRepo instanceof PlatformRepository) {
  4593. $platformRepo = $candidateRepo;
  4594. break;
  4595. }
  4596. }
  4597. }
  4598. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  4599. $require = $input->getOption('require');
  4600. $requirements = array();
  4601. if ($require || $io->askConfirmation($question)) {
  4602. $requirements = $this->determineRequirements($input, $output, $require, $platformRepo, $preferredStability);
  4603. }
  4604. $input->setOption('require', $requirements);
  4605. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  4606. $requireDev = $input->getOption('require-dev');
  4607. $devRequirements = array();
  4608. if ($requireDev || $io->askConfirmation($question)) {
  4609. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $platformRepo, $preferredStability);
  4610. }
  4611. $input->setOption('require-dev', $devRequirements);
  4612. $autoload = $input->getOption('autoload') ?: 'src/';
  4613. $namespace = $this->namespaceFromPackageName($input->getOption('name'));
  4614. $autoload = $io->askAndValidate(
  4615. 'Add PSR-4 autoload mapping? Maps namespace "'.$namespace.'" to the entered relative path. [<comment>'.$autoload.'</comment>, n to skip]: ',
  4616. function ($value) use ($autoload) {
  4617. if (null === $value) {
  4618. return $autoload;
  4619. }
  4620. if ($value === 'n' || $value === 'no') {
  4621. return;
  4622. }
  4623. $value = $value ?: $autoload;
  4624. if (!preg_match('{^[^/][A-Za-z0-9\-_/]+/$}', $value)) {
  4625. throw new \InvalidArgumentException(sprintf(
  4626. 'The src folder name "%s" is invalid. Please add a relative path with tailing forward slash. [A-Za-z0-9_-/]+/',
  4627. $value
  4628. ));
  4629. }
  4630. return $value;
  4631. },
  4632. null,
  4633. $autoload
  4634. );
  4635. $input->setOption('autoload', $autoload);
  4636. }
  4637. public function parseAuthorString($author)
  4638. {
  4639. if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+) <(?P<email>.+?)>$/u', $author, $match)) {
  4640. if ($this->isValidEmail($match['email'])) {
  4641. return array(
  4642. 'name' => trim($match['name']),
  4643. 'email' => $match['email'],
  4644. );
  4645. }
  4646. }
  4647. throw new \InvalidArgumentException(
  4648. 'Invalid author string. Must be in the format: '.
  4649. 'John Smith <john@example.com>'
  4650. );
  4651. }
  4652. protected function findPackages($name)
  4653. {
  4654. return $this->getRepos()->search($name);
  4655. }
  4656. protected function getRepos()
  4657. {
  4658. if (!$this->repos) {
  4659. $this->repos = new CompositeRepository(array_merge(
  4660. array(new PlatformRepository),
  4661. RepositoryFactory::defaultRepos($this->getIO())
  4662. ));
  4663. }
  4664. return $this->repos;
  4665. }
  4666. final protected function determineRequirements(InputInterface $input, OutputInterface $output, $requires = array(), PlatformRepository $platformRepo = null, $preferredStability = 'stable', $checkProvidedVersions = true, $fixed = false)
  4667. {
  4668. if ($requires) {
  4669. $requires = $this->normalizeRequirements($requires);
  4670. $result = array();
  4671. $io = $this->getIO();
  4672. foreach ($requires as $requirement) {
  4673. if (!isset($requirement['version'])) {
  4674. list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, null, null, $fixed);
  4675. $requirement['version'] = $version;
  4676. $requirement['name'] = $name;
  4677. $io->writeError(sprintf(
  4678. 'Using version <info>%s</info> for <info>%s</info>',
  4679. $requirement['version'],
  4680. $requirement['name']
  4681. ));
  4682. } else {
  4683. list($name) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev', $fixed);
  4684. $requirement['name'] = $name;
  4685. }
  4686. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  4687. }
  4688. return $result;
  4689. }
  4690. $versionParser = new VersionParser();
  4691. $composer = $this->getComposer(false);
  4692. $installedRepo = $composer ? $composer->getRepositoryManager()->getLocalRepository() : null;
  4693. $existingPackages = array();
  4694. if ($installedRepo) {
  4695. foreach ($installedRepo->getPackages() as $package) {
  4696. $existingPackages[] = $package->getName();
  4697. }
  4698. }
  4699. unset($composer, $installedRepo);
  4700. $io = $this->getIO();
  4701. while (null !== $package = $io->ask('Search for a package: ')) {
  4702. $matches = $this->findPackages($package);
  4703. if (count($matches)) {
  4704. foreach ($matches as $position => $foundPackage) {
  4705. if (in_array($foundPackage['name'], $existingPackages, true)) {
  4706. unset($matches[$position]);
  4707. }
  4708. }
  4709. $matches = array_values($matches);
  4710. $exactMatch = null;
  4711. $choices = array();
  4712. foreach ($matches as $position => $foundPackage) {
  4713. $abandoned = '';
  4714. if (isset($foundPackage['abandoned'])) {
  4715. if (is_string($foundPackage['abandoned'])) {
  4716. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  4717. } else {
  4718. $replacement = 'No replacement was suggested';
  4719. }
  4720. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  4721. }
  4722. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  4723. if ($foundPackage['name'] === $package) {
  4724. $exactMatch = true;
  4725. break;
  4726. }
  4727. }
  4728. if (!$exactMatch) {
  4729. $io->writeError(array(
  4730. '',
  4731. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  4732. '',
  4733. ));
  4734. $io->writeError($choices);
  4735. $io->writeError('');
  4736. $validator = function ($selection) use ($matches, $versionParser) {
  4737. if ('' === $selection) {
  4738. return false;
  4739. }
  4740. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  4741. $package = $matches[(int) $selection];
  4742. return $package['name'];
  4743. }
  4744. if (preg_match('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  4745. if (isset($packageMatches['version'])) {
  4746. $versionParser->parseConstraints($packageMatches['version']);
  4747. return $packageMatches['name'].' '.$packageMatches['version'];
  4748. }
  4749. return $packageMatches['name'];
  4750. }
  4751. throw new \Exception('Not a valid selection');
  4752. };
  4753. $package = $io->askAndValidate(
  4754. 'Enter package # to add, or the complete package name if it is not listed: ',
  4755. $validator,
  4756. 3,
  4757. false
  4758. );
  4759. }
  4760. if (false !== $package && false === strpos($package, ' ')) {
  4761. $validator = function ($input) {
  4762. $input = trim($input);
  4763. return $input ?: false;
  4764. };
  4765. $constraint = $io->askAndValidate(
  4766. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  4767. $validator,
  4768. 3,
  4769. false
  4770. );
  4771. if (false === $constraint) {
  4772. list(, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $platformRepo, $preferredStability);
  4773. $io->writeError(sprintf(
  4774. 'Using version <info>%s</info> for <info>%s</info>',
  4775. $constraint,
  4776. $package
  4777. ));
  4778. }
  4779. $package .= ' '.$constraint;
  4780. }
  4781. if (false !== $package) {
  4782. $requires[] = $package;
  4783. $existingPackages[] = substr($package, 0, strpos($package, ' '));
  4784. }
  4785. }
  4786. }
  4787. return $requires;
  4788. }
  4789. protected function formatAuthors($author)
  4790. {
  4791. return array($this->parseAuthorString($author));
  4792. }
  4793. public function namespaceFromPackageName($packageName)
  4794. {
  4795. if (!$packageName || strpos($packageName, '/') === false) {
  4796. return null;
  4797. }
  4798. $namespace = array_map(
  4799. function ($part) {
  4800. $part = preg_replace('/[^a-z0-9]/i', ' ', $part);
  4801. $part = ucwords($part);
  4802. return str_replace(' ', '', $part);
  4803. },
  4804. explode('/', $packageName)
  4805. );
  4806. return join('\\', $namespace);
  4807. }
  4808. protected function getGitConfig()
  4809. {
  4810. if (null !== $this->gitConfig) {
  4811. return $this->gitConfig;
  4812. }
  4813. $finder = new ExecutableFinder();
  4814. $gitBin = $finder->find('git');
  4815. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  4816. $cmd = new Process(array($gitBin, 'config', '-l'));
  4817. } else {
  4818. $cmd = new Process(sprintf('%s config -l', ProcessExecutor::escape($gitBin)));
  4819. }
  4820. $cmd->run();
  4821. if ($cmd->isSuccessful()) {
  4822. $this->gitConfig = array();
  4823. preg_match_all('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches, PREG_SET_ORDER);
  4824. foreach ($matches as $match) {
  4825. $this->gitConfig[$match[1]] = $match[2];
  4826. }
  4827. return $this->gitConfig;
  4828. }
  4829. return $this->gitConfig = array();
  4830. }
  4831. protected function hasVendorIgnore($ignoreFile, $vendor = 'vendor')
  4832. {
  4833. if (!file_exists($ignoreFile)) {
  4834. return false;
  4835. }
  4836. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  4837. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  4838. foreach ($lines as $line) {
  4839. if (preg_match($pattern, $line)) {
  4840. return true;
  4841. }
  4842. }
  4843. return false;
  4844. }
  4845. protected function addVendorIgnore($ignoreFile, $vendor = '/vendor/')
  4846. {
  4847. $contents = "";
  4848. if (file_exists($ignoreFile)) {
  4849. $contents = file_get_contents($ignoreFile);
  4850. if (strpos($contents, "\n") !== 0) {
  4851. $contents .= "\n";
  4852. }
  4853. }
  4854. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  4855. }
  4856. protected function isValidEmail($email)
  4857. {
  4858. if (!function_exists('filter_var')) {
  4859. return true;
  4860. }
  4861. if (PHP_VERSION_ID < 50303) {
  4862. return true;
  4863. }
  4864. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  4865. }
  4866. private function getRepositorySet(InputInterface $input, $minimumStability = null)
  4867. {
  4868. $key = $minimumStability ?: 'default';
  4869. if (!isset($this->repositorySets[$key])) {
  4870. $this->repositorySets[$key] = $repositorySet = new RepositorySet($minimumStability ?: $this->getMinimumStability($input));
  4871. $repositorySet->addRepository($this->getRepos());
  4872. }
  4873. return $this->repositorySets[$key];
  4874. }
  4875. private function getMinimumStability(InputInterface $input)
  4876. {
  4877. if ($input->hasOption('stability')) {
  4878. return VersionParser::normalizeStability($input->getOption('stability') ?: 'stable');
  4879. }
  4880. $file = Factory::getComposerFile();
  4881. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  4882. if (!empty($composer['minimum-stability'])) {
  4883. return VersionParser::normalizeStability($composer['minimum-stability']);
  4884. }
  4885. }
  4886. return 'stable';
  4887. }
  4888. private function findBestVersionAndNameForPackage(InputInterface $input, $name, PlatformRepository $platformRepo = null, $preferredStability = 'stable', $requiredVersion = null, $minimumStability = null, $fixed = null)
  4889. {
  4890. $ignorePlatformReqs = false;
  4891. if ($input->hasOption('ignore-platform-reqs') && $input->hasOption('ignore-platform-req')) {
  4892. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4893. }
  4894. $versionSelector = new VersionSelector($this->getRepositorySet($input, $minimumStability), $platformRepo);
  4895. $effectiveMinimumStability = $minimumStability ?: $this->getMinimumStability($input);
  4896. $package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs);
  4897. if (!$package) {
  4898. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($name, $ignorePlatformReqs))) && PlatformRepository::isPlatformPackage($name)) {
  4899. return array($name, $requiredVersion ?: '*');
  4900. }
  4901. if (true !== $ignorePlatformReqs && ($candidate = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, true))) {
  4902. throw new \InvalidArgumentException(sprintf(
  4903. 'Package %s%s has requirements incompatible with your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo),
  4904. $name,
  4905. $requiredVersion ? ' at version '.$requiredVersion : ''
  4906. ));
  4907. }
  4908. if ($package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  4909. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  4910. throw new \InvalidArgumentException(
  4911. '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.'
  4912. );
  4913. }
  4914. throw new \InvalidArgumentException(sprintf(
  4915. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  4916. $name,
  4917. $effectiveMinimumStability
  4918. ));
  4919. }
  4920. if ($requiredVersion && $package = $versionSelector->findBestCandidate($name, null, $preferredStability, $ignorePlatformReqs)) {
  4921. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, false, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  4922. throw new \InvalidArgumentException(
  4923. '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.'
  4924. );
  4925. }
  4926. throw new \InvalidArgumentException(sprintf(
  4927. 'Could not find package %s in a version matching "%s" and a stability matching "'.$effectiveMinimumStability.'".',
  4928. $name,
  4929. $requiredVersion
  4930. ));
  4931. }
  4932. if (true !== $ignorePlatformReqs && ($candidate = $versionSelector->findBestCandidate($name, null, $preferredStability, true, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES))) {
  4933. $additional = '';
  4934. if (false === $versionSelector->findBestCandidate($name, null, $preferredStability, true)) {
  4935. $additional = PHP_EOL.PHP_EOL.'Additionally, the package was only found with a stability of "'.$candidate->getStability().'" while your minimum stability is "'.$effectiveMinimumStability.'".';
  4936. }
  4937. throw new \InvalidArgumentException(sprintf(
  4938. 'Could not find package %s in any version matching your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo) . '%s',
  4939. $name,
  4940. $additional
  4941. ));
  4942. }
  4943. $similar = $this->findSimilar($name);
  4944. if ($similar) {
  4945. if (in_array($name, $similar, true)) {
  4946. throw new \InvalidArgumentException(sprintf(
  4947. "Could not find package %s. It was however found via repository search, which indicates a consistency issue with the repository.",
  4948. $name
  4949. ));
  4950. }
  4951. throw new \InvalidArgumentException(sprintf(
  4952. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  4953. $name,
  4954. implode("\n ", $similar)
  4955. ));
  4956. }
  4957. throw new \InvalidArgumentException(sprintf(
  4958. '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).',
  4959. $name,
  4960. $effectiveMinimumStability
  4961. ));
  4962. }
  4963. return array(
  4964. $package->getPrettyName(),
  4965. $fixed ? $package->getPrettyVersion() : $versionSelector->findRecommendedRequireVersion($package),
  4966. );
  4967. }
  4968. private function getPlatformExceptionDetails(PackageInterface $candidate, PlatformRepository $platformRepo = null)
  4969. {
  4970. $details = array();
  4971. if (!$platformRepo) {
  4972. return '';
  4973. }
  4974. foreach ($candidate->getRequires() as $link) {
  4975. if (!PlatformRepository::isPlatformPackage($link->getTarget())) {
  4976. continue;
  4977. }
  4978. $platformPkg = $platformRepo->findPackage($link->getTarget(), '*');
  4979. if (!$platformPkg) {
  4980. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' but it is not present.';
  4981. continue;
  4982. }
  4983. if (!$link->getConstraint()->matches(new Constraint('==', $platformPkg->getVersion()))) {
  4984. $platformPkgVersion = $platformPkg->getPrettyVersion();
  4985. $platformExtra = $platformPkg->getExtra();
  4986. if (isset($platformExtra['config.platform']) && $platformPkg instanceof CompletePackageInterface) {
  4987. $platformPkgVersion .= ' ('.$platformPkg->getDescription().')';
  4988. }
  4989. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' which does not match your installed version '.$platformPkgVersion.'.';
  4990. }
  4991. }
  4992. if (!$details) {
  4993. return '';
  4994. }
  4995. return ':'.PHP_EOL.' - ' . implode(PHP_EOL.' - ', $details);
  4996. }
  4997. private function findSimilar($package)
  4998. {
  4999. try {
  5000. $results = $this->repos->search($package);
  5001. } catch (\Exception $e) {
  5002. return array();
  5003. }
  5004. $similarPackages = array();
  5005. $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
  5006. foreach ($results as $result) {
  5007. if ($installedRepo->findPackage($result['name'], '*')) {
  5008. continue;
  5009. }
  5010. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  5011. }
  5012. asort($similarPackages);
  5013. return array_keys(array_slice($similarPackages, 0, 5));
  5014. }
  5015. private function updateDependencies(OutputInterface $output)
  5016. {
  5017. try {
  5018. $updateCommand = $this->getApplication()->find('update');
  5019. $this->getApplication()->resetComposer();
  5020. $updateCommand->run(new ArrayInput(array()), $output);
  5021. } catch (\Exception $e) {
  5022. $this->getIO()->writeError('Could not update dependencies. Run `composer update` to see more information.');
  5023. }
  5024. }
  5025. private function runDumpAutoloadCommand(OutputInterface $output)
  5026. {
  5027. try {
  5028. $command = $this->getApplication()->find('dump-autoload');
  5029. $this->getApplication()->resetComposer();
  5030. $command->run(new ArrayInput(array()), $output);
  5031. } catch (\Exception $e) {
  5032. $this->getIO()->writeError('Could not run dump-autoload.');
  5033. }
  5034. }
  5035. private function hasDependencies($options)
  5036. {
  5037. $requires = (array) $options['require'];
  5038. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
  5039. return !empty($requires) || !empty($devRequires);
  5040. }
  5041. }
  5042. <?php
  5043. namespace Composer\Command;
  5044. use Composer\Installer;
  5045. use Composer\Plugin\CommandEvent;
  5046. use Composer\Plugin\PluginEvents;
  5047. use Composer\Util\HttpDownloader;
  5048. use Symfony\Component\Console\Input\InputInterface;
  5049. use Symfony\Component\Console\Input\InputOption;
  5050. use Symfony\Component\Console\Input\InputArgument;
  5051. use Symfony\Component\Console\Output\OutputInterface;
  5052. class InstallCommand extends BaseCommand
  5053. {
  5054. protected function configure()
  5055. {
  5056. $this
  5057. ->setName('install')
  5058. ->setAliases(array('i'))
  5059. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.')
  5060. ->setDefinition(array(
  5061. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5062. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  5063. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  5064. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5065. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  5066. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5067. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  5068. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  5069. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  5070. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5071. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  5072. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  5073. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5074. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5075. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5076. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5077. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5078. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5079. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  5080. ))
  5081. ->setHelp(
  5082. <<<EOT
  5083. The <info>install</info> command reads the composer.lock file from
  5084. the current directory, processes it, and downloads and installs all the
  5085. libraries and dependencies outlined in that file. If the file does not
  5086. exist it will look for composer.json and do the same.
  5087. <info>php composer.phar install</info>
  5088. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  5089. EOT
  5090. )
  5091. ;
  5092. }
  5093. protected function execute(InputInterface $input, OutputInterface $output)
  5094. {
  5095. $io = $this->getIO();
  5096. if ($input->getOption('dev')) {
  5097. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  5098. }
  5099. if ($input->getOption('no-suggest')) {
  5100. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5101. }
  5102. if ($args = $input->getArgument('packages')) {
  5103. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  5104. return 1;
  5105. }
  5106. if ($input->getOption('no-install')) {
  5107. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  5108. return 1;
  5109. }
  5110. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5111. $composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
  5112. if ((!$composer->getLocker() || !$composer->getLocker()->isLocked()) && !HttpDownloader::isCurlEnabled()) {
  5113. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  5114. }
  5115. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  5116. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5117. $install = Installer::create($io, $composer);
  5118. $config = $composer->getConfig();
  5119. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  5120. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  5121. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  5122. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5123. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  5124. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5125. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5126. $install
  5127. ->setDryRun($input->getOption('dry-run'))
  5128. ->setVerbose($input->getOption('verbose'))
  5129. ->setPreferSource($preferSource)
  5130. ->setPreferDist($preferDist)
  5131. ->setDevMode(!$input->getOption('no-dev'))
  5132. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  5133. ->setOptimizeAutoloader($optimize)
  5134. ->setClassMapAuthoritative($authoritative)
  5135. ->setApcuAutoloader($apcu, $apcuPrefix)
  5136. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5137. ;
  5138. if ($input->getOption('no-plugins')) {
  5139. $install->disablePlugins();
  5140. }
  5141. return $install->run();
  5142. }
  5143. }
  5144. <?php
  5145. namespace Composer\Command;
  5146. use Composer\Json\JsonFile;
  5147. use Composer\Package\CompletePackageInterface;
  5148. use Composer\Plugin\CommandEvent;
  5149. use Composer\Plugin\PluginEvents;
  5150. use Composer\Package\PackageInterface;
  5151. use Composer\Repository\RepositoryInterface;
  5152. use Symfony\Component\Console\Helper\Table;
  5153. use Symfony\Component\Console\Input\InputInterface;
  5154. use Symfony\Component\Console\Input\InputOption;
  5155. use Symfony\Component\Console\Output\OutputInterface;
  5156. use Symfony\Component\Console\Style\SymfonyStyle;
  5157. class LicensesCommand extends BaseCommand
  5158. {
  5159. protected function configure()
  5160. {
  5161. $this
  5162. ->setName('licenses')
  5163. ->setDescription('Shows information about licenses of dependencies.')
  5164. ->setDefinition(array(
  5165. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text'),
  5166. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  5167. ))
  5168. ->setHelp(
  5169. <<<EOT
  5170. The license command displays detailed information about the licenses of
  5171. the installed dependencies.
  5172. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  5173. EOT
  5174. )
  5175. ;
  5176. }
  5177. protected function execute(InputInterface $input, OutputInterface $output)
  5178. {
  5179. $composer = $this->getComposer();
  5180. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  5181. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5182. $root = $composer->getPackage();
  5183. $repo = $composer->getRepositoryManager()->getLocalRepository();
  5184. if ($input->getOption('no-dev')) {
  5185. $packages = $this->filterRequiredPackages($repo, $root);
  5186. } else {
  5187. $packages = $this->appendPackages($repo->getPackages(), array());
  5188. }
  5189. ksort($packages);
  5190. $io = $this->getIO();
  5191. switch ($format = $input->getOption('format')) {
  5192. case 'text':
  5193. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  5194. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  5195. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  5196. $io->write('Dependencies:');
  5197. $io->write('');
  5198. $table = new Table($output);
  5199. $table->setStyle('compact');
  5200. $tableStyle = $table->getStyle();
  5201. if (method_exists($tableStyle, 'setVerticalBorderChars')) {
  5202. $tableStyle->setVerticalBorderChars('');
  5203. } else {
  5204. $tableStyle->setVerticalBorderChar('');
  5205. }
  5206. $tableStyle->setCellRowContentFormat('%s ');
  5207. $table->setHeaders(array('Name', 'Version', 'License'));
  5208. foreach ($packages as $package) {
  5209. $table->addRow(array(
  5210. $package->getPrettyName(),
  5211. $package->getFullPrettyVersion(),
  5212. implode(', ', $package instanceof CompletePackageInterface ? $package->getLicense() : array()) ?: 'none',
  5213. ));
  5214. }
  5215. $table->render();
  5216. break;
  5217. case 'json':
  5218. $dependencies = array();
  5219. foreach ($packages as $package) {
  5220. $dependencies[$package->getPrettyName()] = array(
  5221. 'version' => $package->getFullPrettyVersion(),
  5222. 'license' => $package instanceof CompletePackageInterface ? $package->getLicense() : array(),
  5223. );
  5224. }
  5225. $io->write(JsonFile::encode(array(
  5226. 'name' => $root->getPrettyName(),
  5227. 'version' => $root->getFullPrettyVersion(),
  5228. 'license' => $root->getLicense(),
  5229. 'dependencies' => $dependencies,
  5230. )));
  5231. break;
  5232. case 'summary':
  5233. $usedLicenses = array();
  5234. foreach ($packages as $package) {
  5235. $license = $package instanceof CompletePackageInterface ? $package->getLicense() : array();
  5236. $licenseName = $license[0];
  5237. if (!isset($usedLicenses[$licenseName])) {
  5238. $usedLicenses[$licenseName] = 0;
  5239. }
  5240. $usedLicenses[$licenseName]++;
  5241. }
  5242. arsort($usedLicenses, SORT_NUMERIC);
  5243. $rows = array();
  5244. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  5245. $rows[] = array($usedLicense, $numberOfDependencies);
  5246. }
  5247. $symfonyIo = new SymfonyStyle($input, $output);
  5248. $symfonyIo->table(
  5249. array('License', 'Number of dependencies'),
  5250. $rows
  5251. );
  5252. break;
  5253. default:
  5254. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  5255. }
  5256. return 0;
  5257. }
  5258. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  5259. {
  5260. $requires = array_keys($package->getRequires());
  5261. $packageListNames = array_keys($bucket);
  5262. $packages = array_filter(
  5263. $repo->getPackages(),
  5264. function ($package) use ($requires, $packageListNames) {
  5265. return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
  5266. }
  5267. );
  5268. $bucket = $this->appendPackages($packages, $bucket);
  5269. foreach ($packages as $package) {
  5270. $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
  5271. }
  5272. return $bucket;
  5273. }
  5274. public function appendPackages(array $packages, array $bucket)
  5275. {
  5276. foreach ($packages as $package) {
  5277. $bucket[$package->getName()] = $package;
  5278. }
  5279. return $bucket;
  5280. }
  5281. }
  5282. <?php
  5283. namespace Composer\Command;
  5284. use Symfony\Component\Console\Input\InputInterface;
  5285. use Symfony\Component\Console\Input\InputArgument;
  5286. use Symfony\Component\Console\Input\ArrayInput;
  5287. use Symfony\Component\Console\Input\InputOption;
  5288. use Symfony\Component\Console\Output\OutputInterface;
  5289. class OutdatedCommand extends ShowCommand
  5290. {
  5291. protected function configure()
  5292. {
  5293. $this
  5294. ->setName('outdated')
  5295. ->setDescription('Shows a list of installed packages that have updates available, including their latest version.')
  5296. ->setDefinition(array(
  5297. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  5298. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  5299. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  5300. new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'),
  5301. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  5302. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  5303. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  5304. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  5305. 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.'),
  5306. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  5307. ))
  5308. ->setHelp(
  5309. <<<EOT
  5310. The outdated command is just a proxy for `composer show -l`
  5311. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  5312. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  5313. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  5314. compatibility breaks according to semver, so upgrade when you can but it
  5315. may involve work.
  5316. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  5317. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  5318. EOT
  5319. )
  5320. ;
  5321. }
  5322. protected function execute(InputInterface $input, OutputInterface $output)
  5323. {
  5324. $args = array(
  5325. 'command' => 'show',
  5326. '--latest' => true,
  5327. );
  5328. if (!$input->getOption('all')) {
  5329. $args['--outdated'] = true;
  5330. }
  5331. if ($input->getOption('direct')) {
  5332. $args['--direct'] = true;
  5333. }
  5334. if ($input->getArgument('package')) {
  5335. $args['package'] = $input->getArgument('package');
  5336. }
  5337. if ($input->getOption('strict')) {
  5338. $args['--strict'] = true;
  5339. }
  5340. if ($input->getOption('minor-only')) {
  5341. $args['--minor-only'] = true;
  5342. }
  5343. if ($input->getOption('locked')) {
  5344. $args['--locked'] = true;
  5345. }
  5346. if ($input->getOption('no-dev')) {
  5347. $args['--no-dev'] = true;
  5348. }
  5349. $args['--format'] = $input->getOption('format');
  5350. $args['--ignore'] = $input->getOption('ignore');
  5351. $input = new ArrayInput($args);
  5352. return $this->getApplication()->run($input, $output);
  5353. }
  5354. public function isProxyCommand()
  5355. {
  5356. return true;
  5357. }
  5358. }
  5359. <?php
  5360. namespace Composer\Command;
  5361. use Symfony\Component\Console\Input\InputInterface;
  5362. use Symfony\Component\Console\Output\OutputInterface;
  5363. use Symfony\Component\Console\Input\InputArgument;
  5364. use Symfony\Component\Console\Input\InputOption;
  5365. class ProhibitsCommand extends BaseDependencyCommand
  5366. {
  5367. protected function configure()
  5368. {
  5369. $this
  5370. ->setName('prohibits')
  5371. ->setAliases(array('why-not'))
  5372. ->setDescription('Shows which packages prevent the given package from being installed.')
  5373. ->setDefinition(array(
  5374. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  5375. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::REQUIRED, 'Version constraint, which version you expected to be installed'),
  5376. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  5377. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  5378. ))
  5379. ->setHelp(
  5380. <<<EOT
  5381. Displays detailed information about why a package cannot be installed.
  5382. <info>php composer.phar prohibits composer/composer</info>
  5383. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not-
  5384. EOT
  5385. )
  5386. ;
  5387. }
  5388. protected function execute(InputInterface $input, OutputInterface $output)
  5389. {
  5390. return parent::doExecute($input, $output, true);
  5391. }
  5392. }
  5393. <?php
  5394. namespace Composer\Command;
  5395. use Composer\DependencyResolver\Operation\InstallOperation;
  5396. use Composer\DependencyResolver\Operation\UninstallOperation;
  5397. use Composer\DependencyResolver\Transaction;
  5398. use Composer\Package\AliasPackage;
  5399. use Composer\Package\BasePackage;
  5400. use Composer\Plugin\CommandEvent;
  5401. use Composer\Plugin\PluginEvents;
  5402. use Symfony\Component\Console\Input\InputInterface;
  5403. use Symfony\Component\Console\Input\InputOption;
  5404. use Symfony\Component\Console\Input\InputArgument;
  5405. use Symfony\Component\Console\Output\OutputInterface;
  5406. class ReinstallCommand extends BaseCommand
  5407. {
  5408. protected function configure()
  5409. {
  5410. $this
  5411. ->setName('reinstall')
  5412. ->setDescription('Uninstalls and reinstalls the given package names')
  5413. ->setDefinition(array(
  5414. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5415. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  5416. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  5417. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  5418. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  5419. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5420. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5421. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5422. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5423. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5424. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5425. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5426. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'List of package names to reinstall, can include a wildcard (*) to match any substring.'),
  5427. ))
  5428. ->setHelp(
  5429. <<<EOT
  5430. The <info>reinstall</info> command looks up installed packages by name,
  5431. uninstalls them and reinstalls them. This lets you do a clean install
  5432. of a package if you messed with its files, or if you wish to change
  5433. the installation type using --prefer-install.
  5434. <info>php composer.phar reinstall acme/foo "acme/bar-*"</info>
  5435. Read more at https://getcomposer.org/doc/03-cli.md#reinstall
  5436. EOT
  5437. )
  5438. ;
  5439. }
  5440. protected function execute(InputInterface $input, OutputInterface $output)
  5441. {
  5442. $io = $this->getIO();
  5443. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5444. $composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
  5445. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5446. $packagesToReinstall = array();
  5447. $packageNamesToReinstall = array();
  5448. foreach ($input->getArgument('packages') as $pattern) {
  5449. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  5450. $matched = false;
  5451. foreach ($localRepo->getCanonicalPackages() as $package) {
  5452. if (preg_match($patternRegexp, $package->getName())) {
  5453. $matched = true;
  5454. $packagesToReinstall[] = $package;
  5455. $packageNamesToReinstall[] = $package->getName();
  5456. }
  5457. }
  5458. if (!$matched) {
  5459. $io->writeError('<warning>Pattern "' . $pattern . '" does not match any currently installed packages.</warning>');
  5460. }
  5461. }
  5462. if (!$packagesToReinstall) {
  5463. $io->writeError('<warning>Found no packages to reinstall, aborting.</warning>');
  5464. return 1;
  5465. }
  5466. $uninstallOperations = array();
  5467. foreach ($packagesToReinstall as $package) {
  5468. $uninstallOperations[] = new UninstallOperation($package);
  5469. }
  5470. $presentPackages = $localRepo->getPackages();
  5471. $resultPackages = $presentPackages;
  5472. foreach ($presentPackages as $index => $package) {
  5473. if (in_array($package->getName(), $packageNamesToReinstall, true)) {
  5474. unset($presentPackages[$index]);
  5475. }
  5476. }
  5477. $transaction = new Transaction($presentPackages, $resultPackages);
  5478. $installOperations = $transaction->getOperations();
  5479. $installOrder = array();
  5480. foreach ($installOperations as $index => $op) {
  5481. if ($op instanceof InstallOperation && !$op->getPackage() instanceof AliasPackage) {
  5482. $installOrder[$op->getPackage()->getName()] = $index;
  5483. }
  5484. }
  5485. usort($uninstallOperations, function ($a, $b) use ($installOrder) {
  5486. return $installOrder[$b->getPackage()->getName()] - $installOrder[$a->getPackage()->getName()];
  5487. });
  5488. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'reinstall', $input, $output);
  5489. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5490. $config = $composer->getConfig();
  5491. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  5492. $installationManager = $composer->getInstallationManager();
  5493. $downloadManager = $composer->getDownloadManager();
  5494. $package = $composer->getPackage();
  5495. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5496. $installationManager->setOutputProgress(!$input->getOption('no-progress'));
  5497. if ($input->getOption('no-plugins')) {
  5498. $installationManager->disablePlugins();
  5499. }
  5500. $downloadManager->setPreferSource($preferSource);
  5501. $downloadManager->setPreferDist($preferDist);
  5502. $installationManager->execute($localRepo, $uninstallOperations, true);
  5503. $installationManager->execute($localRepo, $installOperations, true);
  5504. if (!$input->getOption('no-autoloader')) {
  5505. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  5506. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  5507. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5508. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  5509. $generator = $composer->getAutoloadGenerator();
  5510. $generator->setClassMapAuthoritative($authoritative);
  5511. $generator->setApcu($apcu, $apcuPrefix);
  5512. $generator->setIgnorePlatformRequirements($ignorePlatformReqs);
  5513. $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  5514. }
  5515. return 0;
  5516. }
  5517. }
  5518. <?php
  5519. namespace Composer\Command;
  5520. use Composer\Config\JsonConfigSource;
  5521. use Composer\DependencyResolver\Request;
  5522. use Composer\Installer;
  5523. use Composer\Plugin\CommandEvent;
  5524. use Composer\Plugin\PluginEvents;
  5525. use Composer\Json\JsonFile;
  5526. use Composer\Factory;
  5527. use Symfony\Component\Console\Input\InputInterface;
  5528. use Symfony\Component\Console\Input\InputOption;
  5529. use Symfony\Component\Console\Input\InputArgument;
  5530. use Symfony\Component\Console\Output\OutputInterface;
  5531. use Composer\Package\BasePackage;
  5532. class RemoveCommand extends BaseCommand
  5533. {
  5534. protected function configure()
  5535. {
  5536. $this
  5537. ->setName('remove')
  5538. ->setDescription('Removes a package from the require or require-dev.')
  5539. ->setDefinition(array(
  5540. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Packages that should be removed.'),
  5541. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  5542. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5543. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5544. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5545. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5546. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  5547. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5548. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecrated, is now default behavior)'),
  5549. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5550. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5551. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  5552. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  5553. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5554. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5555. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5556. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5557. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5558. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5559. ))
  5560. ->setHelp(
  5561. <<<EOT
  5562. The <info>remove</info> command removes a package from the current
  5563. list of installed packages
  5564. <info>php composer.phar remove</info>
  5565. Read more at https://getcomposer.org/doc/03-cli.md#remove
  5566. EOT
  5567. )
  5568. ;
  5569. }
  5570. protected function interact(InputInterface $input, OutputInterface $output)
  5571. {
  5572. if ($input->getOption('unused')) {
  5573. $composer = $this->getComposer();
  5574. $locker = $composer->getLocker();
  5575. if (!$locker->isLocked()) {
  5576. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  5577. }
  5578. $lockedPackages = $locker->getLockedRepository()->getPackages();
  5579. $required = array();
  5580. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  5581. $required[$link->getTarget()] = true;
  5582. }
  5583. do {
  5584. $found = false;
  5585. foreach ($lockedPackages as $index => $package) {
  5586. foreach ($package->getNames() as $name) {
  5587. if (isset($required[$name])) {
  5588. foreach ($package->getRequires() as $link) {
  5589. $required[$link->getTarget()] = true;
  5590. }
  5591. $found = true;
  5592. unset($lockedPackages[$index]);
  5593. break;
  5594. }
  5595. }
  5596. }
  5597. } while ($found);
  5598. $unused = array();
  5599. foreach ($lockedPackages as $package) {
  5600. $unused[] = $package->getName();
  5601. }
  5602. $input->setArgument('packages', array_merge($input->getArgument('packages'), $unused));
  5603. if (!$input->getArgument('packages')) {
  5604. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  5605. $this->setCode(function () {
  5606. return 0;
  5607. });
  5608. }
  5609. }
  5610. }
  5611. protected function execute(InputInterface $input, OutputInterface $output)
  5612. {
  5613. $packages = $input->getArgument('packages');
  5614. $packages = array_map('strtolower', $packages);
  5615. $file = Factory::getComposerFile();
  5616. $jsonFile = new JsonFile($file);
  5617. $composer = $jsonFile->read();
  5618. $composerBackup = file_get_contents($jsonFile->getPath());
  5619. $json = new JsonConfigSource($jsonFile);
  5620. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  5621. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  5622. $io = $this->getIO();
  5623. if ($input->getOption('update-with-dependencies')) {
  5624. $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>');
  5625. }
  5626. foreach (array('require', 'require-dev') as $linkType) {
  5627. if (isset($composer[$linkType])) {
  5628. foreach ($composer[$linkType] as $name => $version) {
  5629. $composer[$linkType][strtolower($name)] = $name;
  5630. }
  5631. }
  5632. }
  5633. $dryRun = $input->getOption('dry-run');
  5634. $toRemove = array();
  5635. foreach ($packages as $package) {
  5636. if (isset($composer[$type][$package])) {
  5637. if ($dryRun) {
  5638. $toRemove[$type][] = $composer[$type][$package];
  5639. } else {
  5640. $json->removeLink($type, $composer[$type][$package]);
  5641. }
  5642. } elseif (isset($composer[$altType][$package])) {
  5643. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5644. if ($io->isInteractive()) {
  5645. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5646. if ($dryRun) {
  5647. $toRemove[$altType][] = $composer[$altType][$package];
  5648. } else {
  5649. $json->removeLink($altType, $composer[$altType][$package]);
  5650. }
  5651. }
  5652. }
  5653. } elseif (isset($composer[$type]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) {
  5654. foreach ($matches as $matchedPackage) {
  5655. if ($dryRun) {
  5656. $toRemove[$type][] = $matchedPackage;
  5657. } else {
  5658. $json->removeLink($type, $matchedPackage);
  5659. }
  5660. }
  5661. } elseif (isset($composer[$altType]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) {
  5662. foreach ($matches as $matchedPackage) {
  5663. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5664. if ($io->isInteractive()) {
  5665. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5666. if ($dryRun) {
  5667. $toRemove[$altType][] = $matchedPackage;
  5668. } else {
  5669. $json->removeLink($altType, $matchedPackage);
  5670. }
  5671. }
  5672. }
  5673. }
  5674. } else {
  5675. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  5676. }
  5677. }
  5678. $io->writeError('<info>'.$file.' has been updated</info>');
  5679. if ($input->getOption('no-update')) {
  5680. return 0;
  5681. }
  5682. $this->resetComposer();
  5683. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5684. $composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
  5685. if ($dryRun) {
  5686. $rootPackage = $composer->getPackage();
  5687. $links = array(
  5688. 'require' => $rootPackage->getRequires(),
  5689. 'require-dev' => $rootPackage->getDevRequires(),
  5690. );
  5691. foreach ($toRemove as $type => $names) {
  5692. foreach ($names as $name) {
  5693. unset($links[$type][$name]);
  5694. }
  5695. }
  5696. $rootPackage->setRequires($links['require']);
  5697. $rootPackage->setDevRequires($links['require-dev']);
  5698. }
  5699. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  5700. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5701. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5702. $install = Installer::create($io, $composer);
  5703. $updateDevMode = !$input->getOption('update-no-dev');
  5704. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5705. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5706. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5707. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5708. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5709. $flags = '';
  5710. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5711. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5712. $flags .= ' --with-all-dependencies';
  5713. } elseif ($input->getOption('no-update-with-dependencies')) {
  5714. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5715. $flags .= ' --with-dependencies';
  5716. }
  5717. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  5718. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5719. $install
  5720. ->setVerbose($input->getOption('verbose'))
  5721. ->setDevMode($updateDevMode)
  5722. ->setOptimizeAutoloader($optimize)
  5723. ->setClassMapAuthoritative($authoritative)
  5724. ->setApcuAutoloader($apcu, $apcuPrefix)
  5725. ->setUpdate(true)
  5726. ->setInstall(!$input->getOption('no-install'))
  5727. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5728. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5729. ->setDryRun($dryRun)
  5730. ;
  5731. if ($composer->getLocker()->isLocked()) {
  5732. $install->setUpdateAllowList($packages);
  5733. }
  5734. $status = $install->run();
  5735. if ($status !== 0) {
  5736. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  5737. file_put_contents($jsonFile->getPath(), $composerBackup);
  5738. }
  5739. if (!$dryRun) {
  5740. foreach ($packages as $package) {
  5741. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  5742. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  5743. return 2;
  5744. }
  5745. }
  5746. }
  5747. return $status;
  5748. }
  5749. }
  5750. <?php
  5751. namespace Composer\Command;
  5752. use Composer\DependencyResolver\Request;
  5753. use Composer\Util\Filesystem;
  5754. use Symfony\Component\Console\Input\InputInterface;
  5755. use Symfony\Component\Console\Input\InputArgument;
  5756. use Symfony\Component\Console\Input\InputOption;
  5757. use Symfony\Component\Console\Output\OutputInterface;
  5758. use Composer\Factory;
  5759. use Composer\Installer;
  5760. use Composer\Installer\InstallerEvents;
  5761. use Composer\Json\JsonFile;
  5762. use Composer\Json\JsonManipulator;
  5763. use Composer\Package\Version\VersionParser;
  5764. use Composer\Package\Loader\ArrayLoader;
  5765. use Composer\Package\BasePackage;
  5766. use Composer\Plugin\CommandEvent;
  5767. use Composer\Plugin\PluginEvents;
  5768. use Composer\Repository\CompositeRepository;
  5769. use Composer\Repository\PlatformRepository;
  5770. use Composer\IO\IOInterface;
  5771. use Composer\Util\Silencer;
  5772. class RequireCommand extends InitCommand
  5773. {
  5774. private $newlyCreated;
  5775. private $firstRequire;
  5776. private $json;
  5777. private $file;
  5778. private $composerBackup;
  5779. private $lock;
  5780. private $lockBackup;
  5781. private $dependencyResolutionCompleted = false;
  5782. protected function configure()
  5783. {
  5784. $this
  5785. ->setName('require')
  5786. ->setDescription('Adds required packages to your composer.json and installs them.')
  5787. ->setDefinition(array(
  5788. 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"'),
  5789. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  5790. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5791. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5792. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  5793. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  5794. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  5795. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5796. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5797. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5798. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5799. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  5800. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5801. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  5802. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5803. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  5804. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5805. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5806. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5807. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  5808. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  5809. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  5810. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5811. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5812. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5813. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5814. ))
  5815. ->setHelp(
  5816. <<<EOT
  5817. The require command adds required packages to your composer.json and installs them.
  5818. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  5819. matches to require.
  5820. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  5821. If you do not want to install the new dependencies immediately you can call it with --no-update
  5822. Read more at https://getcomposer.org/doc/03-cli.md#require
  5823. EOT
  5824. )
  5825. ;
  5826. }
  5827. protected function execute(InputInterface $input, OutputInterface $output)
  5828. {
  5829. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  5830. pcntl_async_signals(true);
  5831. pcntl_signal(SIGINT, array($this, 'revertComposerFile'));
  5832. pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));
  5833. pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));
  5834. }
  5835. $this->file = Factory::getComposerFile();
  5836. $io = $this->getIO();
  5837. if ($input->getOption('no-suggest')) {
  5838. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5839. }
  5840. $this->newlyCreated = !file_exists($this->file);
  5841. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  5842. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  5843. return 1;
  5844. }
  5845. if (!Filesystem::isReadable($this->file)) {
  5846. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  5847. return 1;
  5848. }
  5849. if (filesize($this->file) === 0) {
  5850. file_put_contents($this->file, "{\n}\n");
  5851. }
  5852. $this->json = new JsonFile($this->file);
  5853. $this->lock = Factory::getLockFile($this->file);
  5854. $this->composerBackup = file_get_contents($this->json->getPath());
  5855. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  5856. if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  5857. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  5858. return 1;
  5859. }
  5860. if ($input->getOption('fixed') === true) {
  5861. $config = $this->json->read();
  5862. $packageType = empty($config['type']) ? 'library' : $config['type'];
  5863. if ($packageType !== 'project') {
  5864. $io->writeError('<error>"--fixed" option is allowed for "project" package types only to prevent possible misuses.</error>');
  5865. if (empty($config['type'])) {
  5866. $io->writeError('<error>If your package is not library, you should explicitly specify "type" parameter in composer.json.</error>');
  5867. }
  5868. return 1;
  5869. }
  5870. }
  5871. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5872. $repos = $composer->getRepositoryManager()->getRepositories();
  5873. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  5874. $this->repos = new CompositeRepository(array_merge(
  5875. array($platformRepo = new PlatformRepository(array(), $platformOverrides)),
  5876. $repos
  5877. ));
  5878. if ($composer->getPackage()->getPreferStable()) {
  5879. $preferredStability = 'stable';
  5880. } else {
  5881. $preferredStability = $composer->getPackage()->getMinimumStability();
  5882. }
  5883. try {
  5884. $requirements = $this->determineRequirements(
  5885. $input,
  5886. $output,
  5887. $input->getArgument('packages'),
  5888. $platformRepo,
  5889. $preferredStability,
  5890. !$input->getOption('no-update'),
  5891. $input->getOption('fixed')
  5892. );
  5893. } catch (\Exception $e) {
  5894. if ($this->newlyCreated) {
  5895. throw new \RuntimeException('No composer.json present in the current directory ('.$this->file.'), this may be the cause of the following exception.', 0, $e);
  5896. }
  5897. throw $e;
  5898. }
  5899. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  5900. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  5901. $requirements = $this->formatRequirements($requirements);
  5902. $versionParser = new VersionParser();
  5903. foreach ($requirements as $package => $constraint) {
  5904. if (strtolower($package) === $composer->getPackage()->getName()) {
  5905. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  5906. return 1;
  5907. }
  5908. $versionParser->parseConstraints($constraint);
  5909. }
  5910. $inconsistentRequireKeys = $this->getInconsistentRequireKeys($requirements, $requireKey);
  5911. if (count($inconsistentRequireKeys) > 0) {
  5912. foreach ($inconsistentRequireKeys as $package) {
  5913. $io->warning(sprintf(
  5914. '%s is currently present in the %s key and you ran the command %s the --dev flag, which would move it to the %s key.',
  5915. $package,
  5916. $removeKey,
  5917. $input->getOption('dev') ? 'with' : 'without',
  5918. $requireKey
  5919. ));
  5920. }
  5921. if ($io->isInteractive()) {
  5922. if (!$io->askConfirmation(sprintf('<info>Do you want to move %s?</info> [<comment>no</comment>]? ', count($inconsistentRequireKeys) > 1 ? 'these requirements' : 'this requirement'), false)) {
  5923. if (!$io->askConfirmation(sprintf('<info>Do you want to re-run the command %s --dev?</info> [<comment>yes</comment>]? ', $input->getOption('dev') ? 'without' : 'with'), true)) {
  5924. return 0;
  5925. }
  5926. list($requireKey, $removeKey) = array($removeKey, $requireKey);
  5927. }
  5928. }
  5929. }
  5930. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  5931. $this->firstRequire = $this->newlyCreated;
  5932. if (!$this->firstRequire) {
  5933. $composerDefinition = $this->json->read();
  5934. if (empty($composerDefinition['require']) && empty($composerDefinition['require-dev'])) {
  5935. $this->firstRequire = true;
  5936. }
  5937. }
  5938. if (!$input->getOption('dry-run') && !$this->updateFileCleanly($this->json, $requirements, $requireKey, $removeKey, $sortPackages)) {
  5939. $composerDefinition = $this->json->read();
  5940. foreach ($requirements as $package => $version) {
  5941. $composerDefinition[$requireKey][$package] = $version;
  5942. unset($composerDefinition[$removeKey][$package]);
  5943. if (isset($composerDefinition[$removeKey]) && count($composerDefinition[$removeKey]) === 0) {
  5944. unset($composerDefinition[$removeKey]);
  5945. }
  5946. }
  5947. $this->json->write($composerDefinition);
  5948. }
  5949. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  5950. if ($input->getOption('no-update')) {
  5951. return 0;
  5952. }
  5953. try {
  5954. return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  5955. } catch (\Exception $e) {
  5956. if (!$this->dependencyResolutionCompleted) {
  5957. $this->revertComposerFile(false);
  5958. }
  5959. throw $e;
  5960. }
  5961. }
  5962. private function getInconsistentRequireKeys(array $newRequirements, $requireKey)
  5963. {
  5964. $requireKeys = $this->getPackagesByRequireKey();
  5965. $inconsistentRequirements = array();
  5966. foreach ($requireKeys as $package => $packageRequireKey) {
  5967. if (!isset($newRequirements[$package])) {
  5968. continue;
  5969. }
  5970. if ($requireKey !== $packageRequireKey) {
  5971. $inconsistentRequirements[] = $package;
  5972. }
  5973. }
  5974. return $inconsistentRequirements;
  5975. }
  5976. private function getPackagesByRequireKey()
  5977. {
  5978. $composerDefinition = $this->json->read();
  5979. $require = array();
  5980. $requireDev = array();
  5981. if (isset($composerDefinition['require'])) {
  5982. $require = $composerDefinition['require'];
  5983. }
  5984. if (isset($composerDefinition['require-dev'])) {
  5985. $requireDev = $composerDefinition['require-dev'];
  5986. }
  5987. return array_merge(
  5988. array_fill_keys(array_keys($require), 'require'),
  5989. array_fill_keys(array_keys($requireDev), 'require-dev')
  5990. );
  5991. }
  5992. public function markSolverComplete()
  5993. {
  5994. $this->dependencyResolutionCompleted = true;
  5995. }
  5996. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey)
  5997. {
  5998. $this->resetComposer();
  5999. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  6000. $composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
  6001. $this->dependencyResolutionCompleted = false;
  6002. $composer->getEventDispatcher()->addListener(InstallerEvents::PRE_OPERATIONS_EXEC, array($this, 'markSolverComplete'), 10000);
  6003. if ($input->getOption('dry-run')) {
  6004. $rootPackage = $composer->getPackage();
  6005. $links = array(
  6006. 'require' => $rootPackage->getRequires(),
  6007. 'require-dev' => $rootPackage->getDevRequires(),
  6008. );
  6009. $loader = new ArrayLoader();
  6010. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['method'], $requirements);
  6011. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  6012. foreach ($requirements as $package => $constraint) {
  6013. unset($links[$removeKey][$package]);
  6014. }
  6015. $rootPackage->setRequires($links['require']);
  6016. $rootPackage->setDevRequires($links['require-dev']);
  6017. }
  6018. $updateDevMode = !$input->getOption('update-no-dev');
  6019. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  6020. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  6021. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  6022. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  6023. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  6024. $flags = '';
  6025. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  6026. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  6027. $flags .= ' --with-all-dependencies';
  6028. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  6029. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  6030. $flags .= ' --with-dependencies';
  6031. }
  6032. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  6033. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  6034. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6035. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  6036. $install = Installer::create($io, $composer);
  6037. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  6038. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($composer->getConfig(), $input);
  6039. $install
  6040. ->setDryRun($input->getOption('dry-run'))
  6041. ->setVerbose($input->getOption('verbose'))
  6042. ->setPreferSource($preferSource)
  6043. ->setPreferDist($preferDist)
  6044. ->setDevMode($updateDevMode)
  6045. ->setOptimizeAutoloader($optimize)
  6046. ->setClassMapAuthoritative($authoritative)
  6047. ->setApcuAutoloader($apcu, $apcuPrefix)
  6048. ->setUpdate(true)
  6049. ->setInstall(!$input->getOption('no-install'))
  6050. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  6051. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  6052. ->setPreferStable($input->getOption('prefer-stable'))
  6053. ->setPreferLowest($input->getOption('prefer-lowest'))
  6054. ;
  6055. if (!$this->firstRequire && $composer->getLocker()->isLocked()) {
  6056. $install->setUpdateAllowList(array_keys($requirements));
  6057. }
  6058. $status = $install->run();
  6059. if ($status !== 0) {
  6060. if ($status === Installer::ERROR_DEPENDENCY_RESOLUTION_FAILED) {
  6061. foreach ($this->normalizeRequirements($input->getArgument('packages')) as $req) {
  6062. if (!isset($req['version'])) {
  6063. $io->writeError('You can also try re-running composer require with an explicit version constraint, e.g. "composer require '.$req['name'].':*" to figure out if any version is installable, or "composer require '.$req['name'].':^2.1" if you know which you need.');
  6064. break;
  6065. }
  6066. }
  6067. }
  6068. $this->revertComposerFile(false);
  6069. }
  6070. return $status;
  6071. }
  6072. private function updateFileCleanly(JsonFile $json, array $new, $requireKey, $removeKey, $sortPackages)
  6073. {
  6074. $contents = file_get_contents($json->getPath());
  6075. $manipulator = new JsonManipulator($contents);
  6076. foreach ($new as $package => $constraint) {
  6077. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  6078. return false;
  6079. }
  6080. if (!$manipulator->removeSubNode($removeKey, $package)) {
  6081. return false;
  6082. }
  6083. }
  6084. $manipulator->removeMainKeyIfEmpty($removeKey);
  6085. file_put_contents($json->getPath(), $manipulator->getContents());
  6086. return true;
  6087. }
  6088. protected function interact(InputInterface $input, OutputInterface $output)
  6089. {
  6090. return;
  6091. }
  6092. public function revertComposerFile($hardExit = true)
  6093. {
  6094. $io = $this->getIO();
  6095. if ($this->newlyCreated) {
  6096. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  6097. unlink($this->json->getPath());
  6098. if (file_exists($this->lock)) {
  6099. unlink($this->lock);
  6100. }
  6101. } else {
  6102. $msg = ' to its ';
  6103. if ($this->lockBackup) {
  6104. $msg = ' and '.$this->lock.' to their ';
  6105. }
  6106. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  6107. file_put_contents($this->json->getPath(), $this->composerBackup);
  6108. if ($this->lockBackup) {
  6109. file_put_contents($this->lock, $this->lockBackup);
  6110. }
  6111. }
  6112. if ($hardExit) {
  6113. exit(1);
  6114. }
  6115. }
  6116. }
  6117. <?php
  6118. namespace Composer\Command;
  6119. use Composer\Script\Event as ScriptEvent;
  6120. use Composer\Script\ScriptEvents;
  6121. use Composer\Util\ProcessExecutor;
  6122. use Composer\Util\Platform;
  6123. use Symfony\Component\Console\Input\InputInterface;
  6124. use Symfony\Component\Console\Input\InputOption;
  6125. use Symfony\Component\Console\Input\InputArgument;
  6126. use Symfony\Component\Console\Output\OutputInterface;
  6127. class RunScriptCommand extends BaseCommand
  6128. {
  6129. protected $scriptEvents = array(
  6130. ScriptEvents::PRE_INSTALL_CMD,
  6131. ScriptEvents::POST_INSTALL_CMD,
  6132. ScriptEvents::PRE_UPDATE_CMD,
  6133. ScriptEvents::POST_UPDATE_CMD,
  6134. ScriptEvents::PRE_STATUS_CMD,
  6135. ScriptEvents::POST_STATUS_CMD,
  6136. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  6137. ScriptEvents::POST_CREATE_PROJECT_CMD,
  6138. ScriptEvents::PRE_ARCHIVE_CMD,
  6139. ScriptEvents::POST_ARCHIVE_CMD,
  6140. ScriptEvents::PRE_AUTOLOAD_DUMP,
  6141. ScriptEvents::POST_AUTOLOAD_DUMP,
  6142. );
  6143. protected function configure()
  6144. {
  6145. $this
  6146. ->setName('run-script')
  6147. ->setAliases(array('run'))
  6148. ->setDescription('Runs the scripts defined in composer.json.')
  6149. ->setDefinition(array(
  6150. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'),
  6151. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  6152. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  6153. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  6154. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  6155. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  6156. ))
  6157. ->setHelp(
  6158. <<<EOT
  6159. The <info>run-script</info> command runs scripts defined in composer.json:
  6160. <info>php composer.phar run-script post-update-cmd</info>
  6161. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  6162. EOT
  6163. )
  6164. ;
  6165. }
  6166. protected function execute(InputInterface $input, OutputInterface $output)
  6167. {
  6168. if ($input->getOption('list')) {
  6169. return $this->listScripts($output);
  6170. }
  6171. if (!$input->getArgument('script')) {
  6172. throw new \RuntimeException('Missing required argument "script"');
  6173. }
  6174. $script = $input->getArgument('script');
  6175. if (!in_array($script, $this->scriptEvents)) {
  6176. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  6177. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  6178. }
  6179. }
  6180. $composer = $this->getComposer();
  6181. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  6182. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  6183. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  6184. if (!$hasListeners) {
  6185. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  6186. }
  6187. $args = $input->getArgument('args');
  6188. if (null !== $timeout = $input->getOption('timeout')) {
  6189. if (!ctype_digit($timeout)) {
  6190. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  6191. }
  6192. ProcessExecutor::setTimeout((int) $timeout);
  6193. }
  6194. Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
  6195. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  6196. }
  6197. protected function listScripts(OutputInterface $output)
  6198. {
  6199. $scripts = $this->getComposer()->getPackage()->getScripts();
  6200. if (!count($scripts)) {
  6201. return 0;
  6202. }
  6203. $io = $this->getIO();
  6204. $io->writeError('<info>scripts:</info>');
  6205. $table = array();
  6206. foreach ($scripts as $name => $script) {
  6207. $description = '';
  6208. try {
  6209. $cmd = $this->getApplication()->find($name);
  6210. if ($cmd instanceof ScriptAliasCommand) {
  6211. $description = $cmd->getDescription();
  6212. }
  6213. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  6214. }
  6215. $table[] = array(' '.$name, $description);
  6216. }
  6217. $this->renderTable($table, $output);
  6218. return 0;
  6219. }
  6220. }
  6221. <?php
  6222. namespace Composer\Command;
  6223. use Symfony\Component\Console\Input\InputInterface;
  6224. use Symfony\Component\Console\Input\InputOption;
  6225. use Symfony\Component\Console\Input\InputArgument;
  6226. use Symfony\Component\Console\Output\OutputInterface;
  6227. class ScriptAliasCommand extends BaseCommand
  6228. {
  6229. private $script;
  6230. private $description;
  6231. public function __construct($script, $description)
  6232. {
  6233. $this->script = $script;
  6234. $this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
  6235. parent::__construct();
  6236. }
  6237. protected function configure()
  6238. {
  6239. $this
  6240. ->setName($this->script)
  6241. ->setDescription($this->description)
  6242. ->setDefinition(array(
  6243. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  6244. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  6245. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  6246. ))
  6247. ->setHelp(
  6248. <<<EOT
  6249. The <info>run-script</info> command runs scripts defined in composer.json:
  6250. <info>php composer.phar run-script post-update-cmd</info>
  6251. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  6252. EOT
  6253. )
  6254. ;
  6255. }
  6256. protected function execute(InputInterface $input, OutputInterface $output)
  6257. {
  6258. $composer = $this->getComposer();
  6259. $args = $input->getArguments();
  6260. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
  6261. }
  6262. }
  6263. <?php
  6264. namespace Composer\Command;
  6265. use Composer\Factory;
  6266. use Composer\Json\JsonFile;
  6267. use Symfony\Component\Console\Input\InputInterface;
  6268. use Symfony\Component\Console\Input\InputArgument;
  6269. use Symfony\Component\Console\Input\InputOption;
  6270. use Symfony\Component\Console\Output\OutputInterface;
  6271. use Composer\Repository\CompositeRepository;
  6272. use Composer\Repository\PlatformRepository;
  6273. use Composer\Repository\RepositoryInterface;
  6274. use Composer\Plugin\CommandEvent;
  6275. use Composer\Plugin\PluginEvents;
  6276. class SearchCommand extends BaseCommand
  6277. {
  6278. protected function configure()
  6279. {
  6280. $this
  6281. ->setName('search')
  6282. ->setDescription('Searches for packages.')
  6283. ->setDefinition(array(
  6284. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in name'),
  6285. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  6286. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6287. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  6288. ))
  6289. ->setHelp(
  6290. <<<EOT
  6291. The search command searches for packages by its name
  6292. <info>php composer.phar search symfony composer</info>
  6293. Read more at https://getcomposer.org/doc/03-cli.md#search
  6294. EOT
  6295. )
  6296. ;
  6297. }
  6298. protected function execute(InputInterface $input, OutputInterface $output)
  6299. {
  6300. $platformRepo = new PlatformRepository;
  6301. $io = $this->getIO();
  6302. $format = $input->getOption('format');
  6303. if (!in_array($format, array('text', 'json'))) {
  6304. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6305. return 1;
  6306. }
  6307. if (!($composer = $this->getComposer(false))) {
  6308. $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins'));
  6309. }
  6310. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6311. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  6312. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  6313. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  6314. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6315. $onlyName = $input->getOption('only-name');
  6316. $type = $input->getOption('type') ?: null;
  6317. $flags = $onlyName ? RepositoryInterface::SEARCH_NAME : RepositoryInterface::SEARCH_FULLTEXT;
  6318. $results = $repos->search(implode(' ', $input->getArgument('tokens')), $flags, $type);
  6319. if ($results && $format === 'text') {
  6320. $width = $this->getTerminalWidth();
  6321. $nameLength = 0;
  6322. foreach ($results as $result) {
  6323. $nameLength = max(strlen($result['name']), $nameLength);
  6324. }
  6325. $nameLength += 1;
  6326. foreach ($results as $result) {
  6327. $description = isset($result['description']) ? $result['description'] : '';
  6328. $remaining = $width - $nameLength - 2;
  6329. if (strlen($description) > $remaining) {
  6330. $description = substr($description, 0, $remaining - 3) . '...';
  6331. }
  6332. $io->write(str_pad($result['name'], $nameLength, ' ') . $description);
  6333. }
  6334. } elseif ($format === 'json') {
  6335. $io->write(JsonFile::encode($results));
  6336. }
  6337. return 0;
  6338. }
  6339. }
  6340. <?php
  6341. namespace Composer\Command;
  6342. use Composer\Composer;
  6343. use Composer\Factory;
  6344. use Composer\Config;
  6345. use Composer\Util\Filesystem;
  6346. use Composer\Util\Platform;
  6347. use Composer\SelfUpdate\Keys;
  6348. use Composer\SelfUpdate\Versions;
  6349. use Composer\IO\IOInterface;
  6350. use Composer\Downloader\FilesystemException;
  6351. use Composer\Downloader\TransportException;
  6352. use Symfony\Component\Console\Input\InputInterface;
  6353. use Symfony\Component\Console\Input\InputOption;
  6354. use Symfony\Component\Console\Input\InputArgument;
  6355. use Symfony\Component\Console\Output\OutputInterface;
  6356. use Symfony\Component\Finder\Finder;
  6357. class SelfUpdateCommand extends BaseCommand
  6358. {
  6359. const HOMEPAGE = 'getcomposer.org';
  6360. const OLD_INSTALL_EXT = '-old.phar';
  6361. protected function configure()
  6362. {
  6363. $this
  6364. ->setName('self-update')
  6365. ->setAliases(array('selfupdate'))
  6366. ->setDescription('Updates composer.phar to the latest version.')
  6367. ->setDefinition(array(
  6368. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  6369. 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'),
  6370. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  6371. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  6372. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  6373. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  6374. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  6375. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  6376. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  6377. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  6378. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  6379. ))
  6380. ->setHelp(
  6381. <<<EOT
  6382. The <info>self-update</info> command checks getcomposer.org for newer
  6383. versions of composer and if found, installs the latest.
  6384. <info>php composer.phar self-update</info>
  6385. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-
  6386. EOT
  6387. )
  6388. ;
  6389. }
  6390. protected function execute(InputInterface $input, OutputInterface $output)
  6391. {
  6392. class_exists('Composer\Util\Platform');
  6393. class_exists('Composer\Downloader\FilesystemException');
  6394. $config = Factory::createConfig();
  6395. if ($config->get('disable-tls') === true) {
  6396. $baseUrl = 'http://' . self::HOMEPAGE;
  6397. } else {
  6398. $baseUrl = 'https://' . self::HOMEPAGE;
  6399. }
  6400. $io = $this->getIO();
  6401. $httpDownloader = Factory::createHttpDownloader($io, $config);
  6402. $versionsUtil = new Versions($config, $httpDownloader);
  6403. $requestedChannel = null;
  6404. foreach (Versions::$channels as $channel) {
  6405. if ($input->getOption($channel)) {
  6406. $requestedChannel = $channel;
  6407. $versionsUtil->setChannel($channel);
  6408. break;
  6409. }
  6410. }
  6411. if ($input->getOption('set-channel-only')) {
  6412. return 0;
  6413. }
  6414. $cacheDir = $config->get('cache-dir');
  6415. $rollbackDir = $config->get('data-dir');
  6416. $home = $config->get('home');
  6417. $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
  6418. if ($input->getOption('update-keys')) {
  6419. $this->fetchKeys($io, $config);
  6420. return 0;
  6421. }
  6422. if (!file_exists($localFilename)) {
  6423. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  6424. }
  6425. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  6426. if (!is_writable($tmpDir)) {
  6427. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  6428. }
  6429. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  6430. $composeUser = posix_getpwuid(posix_geteuid());
  6431. $homeOwner = posix_getpwuid(fileowner($home));
  6432. if (isset($composeUser['name'], $homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
  6433. $io->writeError('<warning>You are running Composer as "'.$composeUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  6434. }
  6435. }
  6436. if ($input->getOption('rollback')) {
  6437. return $this->rollback($output, $rollbackDir, $localFilename);
  6438. }
  6439. $latest = $versionsUtil->getLatest();
  6440. $latestStable = $versionsUtil->getLatest('stable');
  6441. try {
  6442. $latestPreview = $versionsUtil->getLatest('preview');
  6443. } catch (\UnexpectedValueException $e) {
  6444. $latestPreview = $latestStable;
  6445. }
  6446. $latestVersion = $latest['version'];
  6447. $updateVersion = $input->getArgument('version') ?: $latestVersion;
  6448. $currentMajorVersion = preg_replace('{^(\d+).*}', '$1', Composer::getVersion());
  6449. $updateMajorVersion = preg_replace('{^(\d+).*}', '$1', $updateVersion);
  6450. $previewMajorVersion = preg_replace('{^(\d+).*}', '$1', $latestPreview['version']);
  6451. if ($versionsUtil->getChannel() === 'stable' && !$input->getArgument('version')) {
  6452. if ($currentMajorVersion < $updateMajorVersion) {
  6453. $skippedVersion = $updateVersion;
  6454. $versionsUtil->setChannel($currentMajorVersion);
  6455. $latest = $versionsUtil->getLatest();
  6456. $latestStable = $versionsUtil->getLatest('stable');
  6457. $latestVersion = $latest['version'];
  6458. $updateVersion = $latestVersion;
  6459. $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>');
  6460. } elseif ($currentMajorVersion < $previewMajorVersion) {
  6461. $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>');
  6462. }
  6463. }
  6464. if ($requestedChannel && is_numeric($requestedChannel) && strpos($latestStable['version'], $requestedChannel) !== 0) {
  6465. $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>');
  6466. }
  6467. if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  6468. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  6469. return 1;
  6470. }
  6471. $channelString = $versionsUtil->getChannel();
  6472. if (is_numeric($channelString)) {
  6473. $channelString .= '.x';
  6474. }
  6475. if (Composer::VERSION === $updateVersion) {
  6476. $io->writeError(
  6477. sprintf(
  6478. '<info>You are already using the latest available Composer version %s (%s channel).</info>',
  6479. $updateVersion,
  6480. $channelString
  6481. )
  6482. );
  6483. if ($input->getOption('clean-backups')) {
  6484. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  6485. }
  6486. return 0;
  6487. }
  6488. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp'.rand(0, 10000000).'.phar';
  6489. $backupFile = sprintf(
  6490. '%s/%s-%s%s',
  6491. $rollbackDir,
  6492. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  6493. preg_replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  6494. self::OLD_INSTALL_EXT
  6495. );
  6496. $updatingToTag = !preg_match('{^[0-9a-f]{40}$}', $updateVersion);
  6497. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $channelString));
  6498. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  6499. try {
  6500. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  6501. } catch (TransportException $e) {
  6502. if ($e->getStatusCode() === 404) {
  6503. throw new \InvalidArgumentException('Version "'.$updateVersion.'" could not be found.', 0, $e);
  6504. }
  6505. throw $e;
  6506. }
  6507. $io->writeError(' ', false);
  6508. $httpDownloader->copy($remoteFilename, $tempFilename);
  6509. $io->writeError('');
  6510. if (!file_exists($tempFilename) || !$signature) {
  6511. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  6512. return 1;
  6513. }
  6514. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  6515. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  6516. } else {
  6517. if (!extension_loaded('openssl')) {
  6518. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  6519. . '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.');
  6520. }
  6521. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  6522. if (!file_exists($sigFile)) {
  6523. file_put_contents(
  6524. $home.'/keys.dev.pub',
  6525. <<<DEVPUBKEY
  6526. -----BEGIN PUBLIC KEY-----
  6527. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  6528. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  6529. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  6530. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  6531. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  6532. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  6533. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  6534. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  6535. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  6536. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  6537. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  6538. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  6539. -----END PUBLIC KEY-----
  6540. DEVPUBKEY
  6541. );
  6542. file_put_contents(
  6543. $home.'/keys.tags.pub',
  6544. <<<TAGSPUBKEY
  6545. -----BEGIN PUBLIC KEY-----
  6546. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  6547. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  6548. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  6549. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  6550. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  6551. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  6552. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  6553. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  6554. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  6555. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  6556. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  6557. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  6558. -----END PUBLIC KEY-----
  6559. TAGSPUBKEY
  6560. );
  6561. }
  6562. $pubkeyid = openssl_pkey_get_public($sigFile);
  6563. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  6564. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) {
  6565. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  6566. }
  6567. $signature = json_decode($signature, true);
  6568. $signature = base64_decode($signature['sha384']);
  6569. $verified = 1 === openssl_verify(file_get_contents($tempFilename), $signature, $pubkeyid, $algo);
  6570. if (PHP_VERSION_ID < 80000) {
  6571. openssl_free_key($pubkeyid);
  6572. }
  6573. if (!$verified) {
  6574. 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');
  6575. }
  6576. }
  6577. if ($input->getOption('clean-backups')) {
  6578. $this->cleanBackups($rollbackDir);
  6579. }
  6580. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  6581. @unlink($tempFilename);
  6582. return 1;
  6583. }
  6584. if (file_exists($backupFile)) {
  6585. $io->writeError(sprintf(
  6586. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  6587. Composer::VERSION
  6588. ));
  6589. } else {
  6590. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  6591. }
  6592. return 0;
  6593. }
  6594. protected function fetchKeys(IOInterface $io, Config $config)
  6595. {
  6596. if (!$io->isInteractive()) {
  6597. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  6598. }
  6599. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  6600. $validator = function ($value) {
  6601. if (!preg_match('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  6602. throw new \UnexpectedValueException('Invalid input');
  6603. }
  6604. return trim($value)."\n";
  6605. };
  6606. $devKey = '';
  6607. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  6608. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  6609. while ($line = $io->ask('')) {
  6610. $devKey .= trim($line)."\n";
  6611. if (trim($line) === '-----END PUBLIC KEY-----') {
  6612. break;
  6613. }
  6614. }
  6615. }
  6616. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  6617. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  6618. $tagsKey = '';
  6619. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  6620. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  6621. while ($line = $io->ask('')) {
  6622. $tagsKey .= trim($line)."\n";
  6623. if (trim($line) === '-----END PUBLIC KEY-----') {
  6624. break;
  6625. }
  6626. }
  6627. }
  6628. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  6629. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  6630. $io->write('Public keys stored in '.$config->get('home'));
  6631. }
  6632. protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
  6633. {
  6634. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  6635. if (!$rollbackVersion) {
  6636. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  6637. }
  6638. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  6639. if (!is_file($oldFile)) {
  6640. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  6641. }
  6642. if (!Filesystem::isReadable($oldFile)) {
  6643. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  6644. }
  6645. $io = $this->getIO();
  6646. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  6647. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  6648. return 1;
  6649. }
  6650. return 0;
  6651. }
  6652. protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null)
  6653. {
  6654. $io = $this->getIO();
  6655. @chmod($newFilename, fileperms($localFilename));
  6656. if (!$this->validatePhar($newFilename, $error)) {
  6657. $io->writeError('<error>The '.($backupTarget ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  6658. if ($backupTarget) {
  6659. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  6660. }
  6661. return false;
  6662. }
  6663. if ($backupTarget) {
  6664. @copy($localFilename, $backupTarget);
  6665. }
  6666. try {
  6667. if (Platform::isWindows()) {
  6668. copy($newFilename, $localFilename);
  6669. @unlink($newFilename);
  6670. } else {
  6671. rename($newFilename, $localFilename);
  6672. }
  6673. return true;
  6674. } catch (\Exception $e) {
  6675. if (!is_writable(dirname($localFilename))
  6676. && $io->isInteractive()
  6677. && $this->isWindowsNonAdminUser()) {
  6678. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  6679. }
  6680. $action = 'Composer '.($backupTarget ? 'update' : 'rollback');
  6681. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  6682. }
  6683. }
  6684. protected function cleanBackups($rollbackDir, $except = null)
  6685. {
  6686. $finder = $this->getOldInstallationFinder($rollbackDir);
  6687. $io = $this->getIO();
  6688. $fs = new Filesystem;
  6689. foreach ($finder as $file) {
  6690. if ($except && $file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  6691. continue;
  6692. }
  6693. $file = (string) $file;
  6694. $io->writeError('<info>Removing: '.$file.'</info>');
  6695. $fs->remove($file);
  6696. }
  6697. }
  6698. protected function getLastBackupVersion($rollbackDir)
  6699. {
  6700. $finder = $this->getOldInstallationFinder($rollbackDir);
  6701. $finder->sortByName();
  6702. $files = iterator_to_array($finder);
  6703. if (count($files)) {
  6704. return basename(end($files), self::OLD_INSTALL_EXT);
  6705. }
  6706. return false;
  6707. }
  6708. protected function getOldInstallationFinder($rollbackDir)
  6709. {
  6710. return Finder::create()
  6711. ->depth(0)
  6712. ->files()
  6713. ->name('*' . self::OLD_INSTALL_EXT)
  6714. ->in($rollbackDir);
  6715. }
  6716. protected function validatePhar($pharFile, &$error)
  6717. {
  6718. if (ini_get('phar.readonly')) {
  6719. return true;
  6720. }
  6721. try {
  6722. $phar = new \Phar($pharFile);
  6723. unset($phar);
  6724. $result = true;
  6725. } catch (\Exception $e) {
  6726. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  6727. throw $e;
  6728. }
  6729. $error = $e->getMessage();
  6730. $result = false;
  6731. }
  6732. return $result;
  6733. }
  6734. protected function isWindowsNonAdminUser()
  6735. {
  6736. if (!Platform::isWindows()) {
  6737. return false;
  6738. }
  6739. exec('fltmc.exe filters', $output, $exitCode);
  6740. return $exitCode !== 0;
  6741. }
  6742. protected function tryAsWindowsAdmin($localFilename, $newFilename)
  6743. {
  6744. $io = $this->getIO();
  6745. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  6746. $helpMessage = 'Please run the self-update command as an Administrator.';
  6747. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  6748. if (!$io->askConfirmation($question, false)) {
  6749. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  6750. return false;
  6751. }
  6752. $tmpFile = tempnam(sys_get_temp_dir(), '');
  6753. $script = $tmpFile.'.vbs';
  6754. rename($tmpFile, $script);
  6755. $checksum = hash_file('sha256', $newFilename);
  6756. $source = str_replace('/', '\\', $newFilename);
  6757. $destination = str_replace('/', '\\', $localFilename);
  6758. $vbs = <<<EOT
  6759. Set UAC = CreateObject("Shell.Application")
  6760. UAC.ShellExecute "cmd.exe", "/c copy /b /y ""$source"" ""$destination""", "", "runas", 0
  6761. Wscript.Sleep(300)
  6762. EOT;
  6763. file_put_contents($script, $vbs);
  6764. exec('"'.$script.'"');
  6765. @unlink($script);
  6766. if ($result = Filesystem::isReadable($localFilename) && (hash_file('sha256', $localFilename) === $checksum)) {
  6767. $io->writeError('<info>Operation succeeded.</info>');
  6768. @unlink($newFilename);
  6769. } else {
  6770. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  6771. }
  6772. return $result;
  6773. }
  6774. }
  6775. <?php
  6776. namespace Composer\Command;
  6777. use Composer\Composer;
  6778. use Composer\DependencyResolver\DefaultPolicy;
  6779. use Composer\Json\JsonFile;
  6780. use Composer\Package\BasePackage;
  6781. use Composer\Package\CompletePackageInterface;
  6782. use Composer\Package\Link;
  6783. use Composer\Package\AliasPackage;
  6784. use Composer\Package\PackageInterface;
  6785. use Composer\Package\Version\VersionParser;
  6786. use Composer\Package\Version\VersionSelector;
  6787. use Composer\Plugin\CommandEvent;
  6788. use Composer\Plugin\PluginEvents;
  6789. use Composer\Repository\InstalledArrayRepository;
  6790. use Composer\Repository\ComposerRepository;
  6791. use Composer\Repository\CompositeRepository;
  6792. use Composer\Repository\FilterRepository;
  6793. use Composer\Repository\PlatformRepository;
  6794. use Composer\Repository\RepositoryFactory;
  6795. use Composer\Repository\InstalledRepository;
  6796. use Composer\Repository\RepositoryInterface;
  6797. use Composer\Repository\RepositorySet;
  6798. use Composer\Repository\RootPackageRepository;
  6799. use Composer\Semver\Constraint\ConstraintInterface;
  6800. use Composer\Semver\Semver;
  6801. use Composer\Spdx\SpdxLicenses;
  6802. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  6803. use Symfony\Component\Console\Input\InputArgument;
  6804. use Symfony\Component\Console\Input\InputInterface;
  6805. use Symfony\Component\Console\Input\InputOption;
  6806. use Symfony\Component\Console\Output\OutputInterface;
  6807. class ShowCommand extends BaseCommand
  6808. {
  6809. protected $versionParser;
  6810. protected $colors;
  6811. private $repositorySet;
  6812. protected function configure()
  6813. {
  6814. $this
  6815. ->setName('show')
  6816. ->setAliases(array('info'))
  6817. ->setDescription('Shows information about packages.')
  6818. ->setDefinition(array(
  6819. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  6820. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  6821. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  6822. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  6823. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  6824. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  6825. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  6826. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  6827. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  6828. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  6829. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  6830. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  6831. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  6832. 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.'),
  6833. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  6834. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  6835. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  6836. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6837. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6838. ))
  6839. ->setHelp(
  6840. <<<EOT
  6841. The show command displays detailed information about a package, or
  6842. lists all packages available.
  6843. Read more at https://getcomposer.org/doc/03-cli.md#show
  6844. EOT
  6845. )
  6846. ;
  6847. }
  6848. protected function execute(InputInterface $input, OutputInterface $output)
  6849. {
  6850. $this->versionParser = new VersionParser;
  6851. if ($input->getOption('tree')) {
  6852. $this->initStyles($output);
  6853. }
  6854. $composer = $this->getComposer(false);
  6855. $io = $this->getIO();
  6856. if ($input->getOption('installed')) {
  6857. $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>');
  6858. }
  6859. if ($input->getOption('outdated')) {
  6860. $input->setOption('latest', true);
  6861. } elseif ($input->getOption('ignore')) {
  6862. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  6863. }
  6864. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  6865. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  6866. return 1;
  6867. }
  6868. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  6869. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  6870. return 1;
  6871. }
  6872. if ($input->getOption('tree') && $input->getOption('latest')) {
  6873. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  6874. return 1;
  6875. }
  6876. if ($input->getOption('tree') && $input->getOption('path')) {
  6877. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  6878. return 1;
  6879. }
  6880. $format = $input->getOption('format');
  6881. if (!in_array($format, array('text', 'json'))) {
  6882. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6883. return 1;
  6884. }
  6885. $platformOverrides = array();
  6886. if ($composer) {
  6887. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  6888. }
  6889. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  6890. $lockedRepo = null;
  6891. if ($input->getOption('self')) {
  6892. $package = $this->getComposer()->getPackage();
  6893. if ($input->getOption('name-only')) {
  6894. $io->write($package->getName());
  6895. return 0;
  6896. }
  6897. $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package)));
  6898. } elseif ($input->getOption('platform')) {
  6899. $repos = $installedRepo = new InstalledRepository(array($platformRepo));
  6900. } elseif ($input->getOption('available')) {
  6901. $installedRepo = new InstalledRepository(array($platformRepo));
  6902. if ($composer) {
  6903. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  6904. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  6905. } else {
  6906. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6907. $repos = new CompositeRepository($defaultRepos);
  6908. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6909. }
  6910. } elseif ($input->getOption('all') && $composer) {
  6911. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6912. $locker = $composer->getLocker();
  6913. if ($locker->isLocked()) {
  6914. $lockedRepo = $locker->getLockedRepository(true);
  6915. $installedRepo = new InstalledRepository(array($lockedRepo, $localRepo, $platformRepo));
  6916. } else {
  6917. $installedRepo = new InstalledRepository(array($localRepo, $platformRepo));
  6918. }
  6919. $repos = new CompositeRepository(array_merge(array(new FilterRepository($installedRepo, array('canonical' => false))), $composer->getRepositoryManager()->getRepositories()));
  6920. } elseif ($input->getOption('all')) {
  6921. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6922. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6923. $installedRepo = new InstalledRepository(array($platformRepo));
  6924. $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
  6925. } elseif ($input->getOption('locked')) {
  6926. if (!$composer || !$composer->getLocker()->isLocked()) {
  6927. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  6928. }
  6929. $locker = $composer->getLocker();
  6930. $lockedRepo = $locker->getLockedRepository(!$input->getOption('no-dev'));
  6931. $repos = $installedRepo = new InstalledRepository(array($lockedRepo));
  6932. } else {
  6933. if (!$composer) {
  6934. $composer = $this->getComposer();
  6935. }
  6936. $rootPkg = $composer->getPackage();
  6937. $repos = $installedRepo = new InstalledRepository(array($composer->getRepositoryManager()->getLocalRepository()));
  6938. if ($input->getOption('no-dev')) {
  6939. $packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
  6940. $repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg) {
  6941. return clone $pkg;
  6942. }, $packages))));
  6943. }
  6944. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  6945. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  6946. }
  6947. }
  6948. if ($composer) {
  6949. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  6950. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6951. }
  6952. if ($input->getOption('latest') && null === $composer) {
  6953. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  6954. $input->setOption('latest', false);
  6955. }
  6956. $packageFilter = $input->getArgument('package');
  6957. if (($packageFilter && false === strpos($packageFilter, '*')) || !empty($package)) {
  6958. if (empty($package)) {
  6959. list($package, $versions) = $this->getPackage($installedRepo, $repos, $input->getArgument('package'), $input->getArgument('version'));
  6960. if (empty($package)) {
  6961. $options = $input->getOptions();
  6962. if (!isset($options['working-dir']) || !file_exists('composer.json')) {
  6963. if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
  6964. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.');
  6965. }
  6966. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
  6967. }
  6968. $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
  6969. return 1;
  6970. }
  6971. } else {
  6972. $versions = array($package->getPrettyVersion() => $package->getVersion());
  6973. }
  6974. $exitCode = 0;
  6975. if ($input->getOption('tree')) {
  6976. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  6977. if ('json' === $format) {
  6978. $io->write(JsonFile::encode(array('installed' => array($arrayTree))));
  6979. } else {
  6980. $this->displayPackageTree(array($arrayTree));
  6981. }
  6982. } else {
  6983. $latestPackage = null;
  6984. if ($input->getOption('latest')) {
  6985. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('minor-only'));
  6986. }
  6987. if (
  6988. $input->getOption('outdated')
  6989. && $input->getOption('strict')
  6990. && $latestPackage
  6991. && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion()
  6992. && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned())
  6993. ) {
  6994. $exitCode = 1;
  6995. }
  6996. if ($input->getOption('path')) {
  6997. $io->write($package->getName(), false);
  6998. $io->write(' ' . strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"));
  6999. return $exitCode;
  7000. }
  7001. if ('json' === $format) {
  7002. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  7003. } else {
  7004. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  7005. }
  7006. }
  7007. return $exitCode;
  7008. }
  7009. if ($input->getOption('tree')) {
  7010. $rootRequires = $this->getRootRequires();
  7011. $packages = $installedRepo->getPackages();
  7012. usort($packages, 'strcmp');
  7013. $arrayTree = array();
  7014. foreach ($packages as $package) {
  7015. if (in_array($package->getName(), $rootRequires, true)) {
  7016. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  7017. }
  7018. }
  7019. if ('json' === $format) {
  7020. $io->write(JsonFile::encode(array('installed' => $arrayTree)));
  7021. } else {
  7022. $this->displayPackageTree($arrayTree);
  7023. }
  7024. return 0;
  7025. }
  7026. $packages = array();
  7027. $packageFilterRegex = null;
  7028. if (null !== $packageFilter) {
  7029. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  7030. }
  7031. $packageListFilter = array();
  7032. if ($input->getOption('direct')) {
  7033. $packageListFilter = $this->getRootRequires();
  7034. }
  7035. if ($input->getOption('path') && null === $composer) {
  7036. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  7037. $input->setOption('path', false);
  7038. }
  7039. foreach ($repos->getRepositories() as $repo) {
  7040. if ($repo === $platformRepo) {
  7041. $type = 'platform';
  7042. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  7043. $type = 'locked';
  7044. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  7045. $type = 'installed';
  7046. } else {
  7047. $type = 'available';
  7048. }
  7049. if ($repo instanceof ComposerRepository) {
  7050. foreach ($repo->getPackageNames($packageFilter) as $name) {
  7051. $packages[$type][$name] = $name;
  7052. }
  7053. } else {
  7054. foreach ($repo->getPackages() as $package) {
  7055. if (!isset($packages[$type][$package->getName()])
  7056. || !is_object($packages[$type][$package->getName()])
  7057. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  7058. ) {
  7059. while ($package instanceof AliasPackage) {
  7060. $package = $package->getAliasOf();
  7061. }
  7062. if (!$packageFilterRegex || preg_match($packageFilterRegex, $package->getName())) {
  7063. if (!$packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  7064. $packages[$type][$package->getName()] = $package;
  7065. }
  7066. }
  7067. }
  7068. }
  7069. }
  7070. }
  7071. $showAllTypes = $input->getOption('all');
  7072. $showLatest = $input->getOption('latest');
  7073. $showMinorOnly = $input->getOption('minor-only');
  7074. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  7075. $indent = $showAllTypes ? ' ' : '';
  7076. $latestPackages = array();
  7077. $exitCode = 0;
  7078. $viewData = array();
  7079. $viewMetaData = array();
  7080. foreach (array('platform' => true, 'locked' => true, 'available' => false, 'installed' => true) as $type => $showVersion) {
  7081. if (isset($packages[$type])) {
  7082. ksort($packages[$type]);
  7083. $nameLength = $versionLength = $latestLength = 0;
  7084. if ($showLatest && $showVersion) {
  7085. foreach ($packages[$type] as $package) {
  7086. if (is_object($package)) {
  7087. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMinorOnly);
  7088. if ($latestPackage === false) {
  7089. continue;
  7090. }
  7091. $latestPackages[$package->getPrettyName()] = $latestPackage;
  7092. }
  7093. }
  7094. }
  7095. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  7096. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  7097. $writeLatest = $writeVersion && $showLatest;
  7098. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  7099. $hasOutdatedPackages = false;
  7100. $viewData[$type] = array();
  7101. foreach ($packages[$type] as $package) {
  7102. $packageViewData = array();
  7103. if (is_object($package)) {
  7104. $latestPackage = null;
  7105. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  7106. $latestPackage = $latestPackages[$package->getPrettyName()];
  7107. }
  7108. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned());
  7109. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  7110. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  7111. continue;
  7112. }
  7113. if ($input->getOption('outdated') || $input->getOption('strict')) {
  7114. $hasOutdatedPackages = true;
  7115. }
  7116. $packageViewData['name'] = $package->getPrettyName();
  7117. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  7118. if ($writeVersion) {
  7119. $packageViewData['version'] = $package->getFullPrettyVersion();
  7120. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  7121. }
  7122. if ($writeLatest && $latestPackage) {
  7123. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  7124. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  7125. $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
  7126. }
  7127. if ($writeDescription && $package instanceof CompletePackageInterface) {
  7128. $packageViewData['description'] = $package->getDescription();
  7129. }
  7130. if ($writePath) {
  7131. $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
  7132. }
  7133. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  7134. $replacement = is_string($latestPackage->getReplacementPackage())
  7135. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  7136. : 'No replacement was suggested';
  7137. $packageWarning = sprintf(
  7138. 'Package %s is abandoned, you should avoid using it. %s.',
  7139. $package->getPrettyName(),
  7140. $replacement
  7141. );
  7142. $packageViewData['warning'] = $packageWarning;
  7143. }
  7144. } else {
  7145. $packageViewData['name'] = $package;
  7146. $nameLength = max($nameLength, strlen($package));
  7147. }
  7148. $viewData[$type][] = $packageViewData;
  7149. }
  7150. $viewMetaData[$type] = array(
  7151. 'nameLength' => $nameLength,
  7152. 'versionLength' => $versionLength,
  7153. 'latestLength' => $latestLength,
  7154. );
  7155. if ($input->getOption('strict') && $hasOutdatedPackages) {
  7156. $exitCode = 1;
  7157. break;
  7158. }
  7159. }
  7160. }
  7161. if ('json' === $format) {
  7162. $io->write(JsonFile::encode($viewData));
  7163. } else {
  7164. if ($input->getOption('latest') && array_filter($viewData)) {
  7165. if (!$io->isDecorated()) {
  7166. $io->writeError('Legend:');
  7167. $io->writeError('! patch or minor release available - update recommended');
  7168. $io->writeError('~ major release available - update possible');
  7169. if (!$input->getOption('outdated')) {
  7170. $io->writeError('= up to date version');
  7171. }
  7172. } else {
  7173. $io->writeError('<info>Color legend:</info>');
  7174. $io->writeError('- <highlight>patch or minor</highlight> release available - update recommended');
  7175. $io->writeError('- <comment>major</comment> release available - update possible');
  7176. if (!$input->getOption('outdated')) {
  7177. $io->writeError('- <info>up to date</info> version');
  7178. }
  7179. }
  7180. }
  7181. $width = $this->getTerminalWidth();
  7182. foreach ($viewData as $type => $packages) {
  7183. $nameLength = $viewMetaData[$type]['nameLength'];
  7184. $versionLength = $viewMetaData[$type]['versionLength'];
  7185. $latestLength = $viewMetaData[$type]['latestLength'];
  7186. $writeVersion = $nameLength + $versionLength + 3 <= $width;
  7187. $writeLatest = $nameLength + $versionLength + $latestLength + 3 <= $width;
  7188. $writeDescription = $nameLength + $versionLength + $latestLength + 24 <= $width;
  7189. if ($writeLatest && !$io->isDecorated()) {
  7190. $latestLength += 2;
  7191. }
  7192. if ($showAllTypes) {
  7193. if ('available' === $type) {
  7194. $io->write('<comment>' . $type . '</comment>:');
  7195. } else {
  7196. $io->write('<info>' . $type . '</info>:');
  7197. }
  7198. }
  7199. foreach ($packages as $package) {
  7200. $io->write($indent . str_pad($package['name'], $nameLength, ' '), false);
  7201. if (isset($package['version']) && $writeVersion) {
  7202. $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false);
  7203. }
  7204. if (isset($package['latest']) && $writeLatest) {
  7205. $latestVersion = $package['latest'];
  7206. $updateStatus = $package['latest-status'];
  7207. $style = $this->updateStatusToVersionStyle($updateStatus);
  7208. if (!$io->isDecorated()) {
  7209. $latestVersion = str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('=', '!', '~'), $updateStatus) . ' ' . $latestVersion;
  7210. }
  7211. $io->write(' <' . $style . '>' . str_pad($latestVersion, $latestLength, ' ') . '</' . $style . '>', false);
  7212. }
  7213. if (isset($package['description']) && $writeDescription) {
  7214. $description = strtok($package['description'], "\r\n");
  7215. $remaining = $width - $nameLength - $versionLength - 4;
  7216. if ($writeLatest) {
  7217. $remaining -= $latestLength;
  7218. }
  7219. if (strlen($description) > $remaining) {
  7220. $description = substr($description, 0, $remaining - 3) . '...';
  7221. }
  7222. $io->write(' ' . $description, false);
  7223. }
  7224. if (isset($package['path'])) {
  7225. $io->write(' ' . $package['path'], false);
  7226. }
  7227. $io->write('');
  7228. if (isset($package['warning'])) {
  7229. $io->write('<warning>' . $package['warning'] . '</warning>');
  7230. }
  7231. }
  7232. if ($showAllTypes) {
  7233. $io->write('');
  7234. }
  7235. }
  7236. }
  7237. return $exitCode;
  7238. }
  7239. protected function getRootRequires()
  7240. {
  7241. $rootPackage = $this->getComposer()->getPackage();
  7242. return array_map(
  7243. 'strtolower',
  7244. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  7245. );
  7246. }
  7247. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  7248. {
  7249. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  7250. }
  7251. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, $name, $version = null)
  7252. {
  7253. $name = strtolower($name);
  7254. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  7255. $policy = new DefaultPolicy();
  7256. $repositorySet = new RepositorySet('dev');
  7257. $repositorySet->allowInstalledRepositories();
  7258. $repositorySet->addRepository($repos);
  7259. $matchedPackage = null;
  7260. $versions = array();
  7261. if (PlatformRepository::isPlatformPackage($name)) {
  7262. $pool = $repositorySet->createPoolWithAllPackages();
  7263. } else {
  7264. $pool = $repositorySet->createPoolForPackage($name);
  7265. }
  7266. $matches = $pool->whatProvides($name, $constraint);
  7267. foreach ($matches as $index => $package) {
  7268. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  7269. $package = $package->getAliasOf();
  7270. }
  7271. if (null === $version && $installedRepo->hasPackage($package)) {
  7272. $matchedPackage = $package;
  7273. }
  7274. $versions[$package->getPrettyVersion()] = $package->getVersion();
  7275. $matches[$index] = $package->getId();
  7276. }
  7277. if (!$matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, $matches)) {
  7278. $matchedPackage = $pool->literalToPackage($preferred[0]);
  7279. }
  7280. return array($matchedPackage, $versions);
  7281. }
  7282. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  7283. {
  7284. $io = $this->getIO();
  7285. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  7286. $this->printLinks($package, Link::TYPE_REQUIRE);
  7287. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  7288. if ($package->getSuggests()) {
  7289. $io->write("\n<info>suggests</info>");
  7290. foreach ($package->getSuggests() as $suggested => $reason) {
  7291. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  7292. }
  7293. }
  7294. $this->printLinks($package, Link::TYPE_PROVIDE);
  7295. $this->printLinks($package, Link::TYPE_CONFLICT);
  7296. $this->printLinks($package, Link::TYPE_REPLACE);
  7297. }
  7298. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  7299. {
  7300. $io = $this->getIO();
  7301. $io->write('<info>name</info> : ' . $package->getPrettyName());
  7302. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  7303. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: array()));
  7304. $this->printVersions($package, $versions, $installedRepo);
  7305. if ($latestPackage) {
  7306. $style = $this->getVersionStyle($latestPackage, $package);
  7307. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  7308. } else {
  7309. $latestPackage = $package;
  7310. }
  7311. $io->write('<info>type</info> : ' . $package->getType());
  7312. $this->printLicenses($package);
  7313. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  7314. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  7315. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  7316. if ($installedRepo->hasPackage($package)) {
  7317. $io->write('<info>path</info> : ' . sprintf('%s', realpath($this->getComposer()->getInstallationManager()->getInstallPath($package))));
  7318. }
  7319. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  7320. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  7321. $replacement = ($latestPackage->getReplacementPackage() !== null)
  7322. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  7323. : null;
  7324. $io->writeError(
  7325. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  7326. );
  7327. }
  7328. if ($package->getSupport()) {
  7329. $io->write("\n<info>support</info>");
  7330. foreach ($package->getSupport() as $type => $value) {
  7331. $io->write('<comment>' . $type . '</comment> : '.$value);
  7332. }
  7333. }
  7334. if ($package->getAutoload()) {
  7335. $io->write("\n<info>autoload</info>");
  7336. foreach ($package->getAutoload() as $type => $autoloads) {
  7337. $io->write('<comment>' . $type . '</comment>');
  7338. if ($type === 'psr-0' || $type === 'psr-4') {
  7339. foreach ($autoloads as $name => $path) {
  7340. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  7341. }
  7342. } elseif ($type === 'classmap') {
  7343. $io->write(implode(', ', $autoloads));
  7344. }
  7345. }
  7346. if ($package->getIncludePaths()) {
  7347. $io->write('<comment>include-path</comment>');
  7348. $io->write(implode(', ', $package->getIncludePaths()));
  7349. }
  7350. }
  7351. }
  7352. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo)
  7353. {
  7354. $versions = array_keys($versions);
  7355. $versions = Semver::rsort($versions);
  7356. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  7357. foreach ($installedPackages as $installedPackage) {
  7358. $installedVersion = $installedPackage->getPrettyVersion();
  7359. $key = array_search($installedVersion, $versions);
  7360. if (false !== $key) {
  7361. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  7362. }
  7363. }
  7364. }
  7365. $versions = implode(', ', $versions);
  7366. $this->getIO()->write('<info>versions</info> : ' . $versions);
  7367. }
  7368. protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
  7369. {
  7370. $title = $title ?: $linkType;
  7371. $io = $this->getIO();
  7372. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  7373. $io->write("\n<info>" . $title . "</info>");
  7374. foreach ($links as $link) {
  7375. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  7376. }
  7377. }
  7378. }
  7379. protected function printLicenses(CompletePackageInterface $package)
  7380. {
  7381. $spdxLicenses = new SpdxLicenses();
  7382. $licenses = $package->getLicense();
  7383. $io = $this->getIO();
  7384. foreach ($licenses as $licenseId) {
  7385. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  7386. if (!$license) {
  7387. $out = $licenseId;
  7388. } else {
  7389. if ($license[1] === true) {
  7390. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  7391. } else {
  7392. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  7393. }
  7394. }
  7395. $io->write('<info>license</info> : ' . $out);
  7396. }
  7397. }
  7398. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  7399. {
  7400. $json = array(
  7401. 'name' => $package->getPrettyName(),
  7402. 'description' => $package->getDescription(),
  7403. 'keywords' => $package->getKeywords() ?: array(),
  7404. 'type' => $package->getType(),
  7405. 'homepage' => $package->getHomepage(),
  7406. 'names' => $package->getNames(),
  7407. );
  7408. $json = $this->appendVersions($json, $versions);
  7409. $json = $this->appendLicenses($json, $package);
  7410. if ($latestPackage) {
  7411. $json['latest'] = $latestPackage->getPrettyVersion();
  7412. } else {
  7413. $latestPackage = $package;
  7414. }
  7415. if ($package->getSourceType()) {
  7416. $json['source'] = array(
  7417. 'type' => $package->getSourceType(),
  7418. 'url' => $package->getSourceUrl(),
  7419. 'reference' => $package->getSourceReference(),
  7420. );
  7421. }
  7422. if ($package->getDistType()) {
  7423. $json['dist'] = array(
  7424. 'type' => $package->getDistType(),
  7425. 'url' => $package->getDistUrl(),
  7426. 'reference' => $package->getDistReference(),
  7427. );
  7428. }
  7429. if ($installedRepo->hasPackage($package)) {
  7430. $json['path'] = realpath($this->getComposer()->getInstallationManager()->getInstallPath($package));
  7431. if ($json['path'] === false) {
  7432. unset($json['path']);
  7433. }
  7434. }
  7435. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  7436. $json['replacement'] = $latestPackage->getReplacementPackage();
  7437. }
  7438. if ($package->getSuggests()) {
  7439. $json['suggests'] = $package->getSuggests();
  7440. }
  7441. if ($package->getSupport()) {
  7442. $json['support'] = $package->getSupport();
  7443. }
  7444. $json = $this->appendAutoload($json, $package);
  7445. if ($package->getIncludePaths()) {
  7446. $json['include_path'] = $package->getIncludePaths();
  7447. }
  7448. $json = $this->appendLinks($json, $package);
  7449. $this->getIO()->write(JsonFile::encode($json));
  7450. }
  7451. private function appendVersions($json, array $versions)
  7452. {
  7453. uasort($versions, 'version_compare');
  7454. $versions = array_keys(array_reverse($versions));
  7455. $json['versions'] = $versions;
  7456. return $json;
  7457. }
  7458. private function appendLicenses($json, CompletePackageInterface $package)
  7459. {
  7460. if ($licenses = $package->getLicense()) {
  7461. $spdxLicenses = new SpdxLicenses();
  7462. $json['licenses'] = array_map(function ($licenseId) use ($spdxLicenses) {
  7463. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  7464. if (!$license) {
  7465. return $licenseId;
  7466. }
  7467. return array(
  7468. 'name' => $license[0],
  7469. 'osi' => $licenseId,
  7470. 'url' => $license[2],
  7471. );
  7472. }, $licenses);
  7473. }
  7474. return $json;
  7475. }
  7476. private function appendAutoload($json, CompletePackageInterface $package)
  7477. {
  7478. if ($package->getAutoload()) {
  7479. $autoload = array();
  7480. foreach ($package->getAutoload() as $type => $autoloads) {
  7481. if ($type === 'psr-0' || $type === 'psr-4') {
  7482. $psr = array();
  7483. foreach ($autoloads as $name => $path) {
  7484. if (!$path) {
  7485. $path = '.';
  7486. }
  7487. $psr[$name ?: '*'] = $path;
  7488. }
  7489. $autoload[$type] = $psr;
  7490. } elseif ($type === 'classmap') {
  7491. $autoload['classmap'] = $autoloads;
  7492. }
  7493. }
  7494. $json['autoload'] = $autoload;
  7495. }
  7496. return $json;
  7497. }
  7498. private function appendLinks($json, CompletePackageInterface $package)
  7499. {
  7500. foreach (Link::$TYPES as $linkType) {
  7501. $json = $this->appendLink($json, $package, $linkType);
  7502. }
  7503. return $json;
  7504. }
  7505. private function appendLink($json, CompletePackageInterface $package, $linkType)
  7506. {
  7507. $links = $package->{'get' . ucfirst($linkType)}();
  7508. if ($links) {
  7509. $json[$linkType] = array();
  7510. foreach ($links as $link) {
  7511. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  7512. }
  7513. }
  7514. return $json;
  7515. }
  7516. protected function initStyles(OutputInterface $output)
  7517. {
  7518. $this->colors = array(
  7519. 'green',
  7520. 'yellow',
  7521. 'cyan',
  7522. 'magenta',
  7523. 'blue',
  7524. );
  7525. foreach ($this->colors as $color) {
  7526. $style = new OutputFormatterStyle($color);
  7527. $output->getFormatter()->setStyle($color, $style);
  7528. }
  7529. }
  7530. protected function displayPackageTree(array $arrayTree)
  7531. {
  7532. $io = $this->getIO();
  7533. foreach ($arrayTree as $package) {
  7534. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  7535. $io->write(' ' . $package['version'], false);
  7536. $io->write(' ' . strtok($package['description'], "\r\n"));
  7537. if (isset($package['requires'])) {
  7538. $requires = $package['requires'];
  7539. $treeBar = '├';
  7540. $j = 0;
  7541. $total = count($requires);
  7542. foreach ($requires as $require) {
  7543. $requireName = $require['name'];
  7544. $j++;
  7545. if ($j === $total) {
  7546. $treeBar = 'â””';
  7547. }
  7548. $level = 1;
  7549. $color = $this->colors[$level];
  7550. $info = sprintf(
  7551. '%s──<%s>%s</%s> %s',
  7552. $treeBar,
  7553. $color,
  7554. $requireName,
  7555. $color,
  7556. $require['version']
  7557. );
  7558. $this->writeTreeLine($info);
  7559. $treeBar = str_replace('â””', ' ', $treeBar);
  7560. $packagesInTree = array($package['name'], $requireName);
  7561. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  7562. }
  7563. }
  7564. }
  7565. }
  7566. protected function generatePackageTree(
  7567. PackageInterface $package,
  7568. InstalledRepository $installedRepo,
  7569. RepositoryInterface $remoteRepos
  7570. ) {
  7571. $requires = $package->getRequires();
  7572. ksort($requires);
  7573. $children = array();
  7574. foreach ($requires as $requireName => $require) {
  7575. $packagesInTree = array($package->getName(), $requireName);
  7576. $treeChildDesc = array(
  7577. 'name' => $requireName,
  7578. 'version' => $require->getPrettyConstraint(),
  7579. );
  7580. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  7581. if ($deepChildren) {
  7582. $treeChildDesc['requires'] = $deepChildren;
  7583. }
  7584. $children[] = $treeChildDesc;
  7585. }
  7586. $tree = array(
  7587. 'name' => $package->getPrettyName(),
  7588. 'version' => $package->getPrettyVersion(),
  7589. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : '',
  7590. );
  7591. if ($children) {
  7592. $tree['requires'] = $children;
  7593. }
  7594. return $tree;
  7595. }
  7596. protected function displayTree(
  7597. $package,
  7598. array $packagesInTree,
  7599. $previousTreeBar = '├',
  7600. $level = 1
  7601. ) {
  7602. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  7603. if (is_array($package) && isset($package['requires'])) {
  7604. $requires = $package['requires'];
  7605. $treeBar = $previousTreeBar . ' ├';
  7606. $i = 0;
  7607. $total = count($requires);
  7608. foreach ($requires as $require) {
  7609. $currentTree = $packagesInTree;
  7610. $i++;
  7611. if ($i === $total) {
  7612. $treeBar = $previousTreeBar . ' â””';
  7613. }
  7614. $colorIdent = $level % count($this->colors);
  7615. $color = $this->colors[$colorIdent];
  7616. $circularWarn = in_array(
  7617. $require['name'],
  7618. $currentTree,
  7619. true
  7620. ) ? '(circular dependency aborted here)' : '';
  7621. $info = rtrim(sprintf(
  7622. '%s──<%s>%s</%s> %s %s',
  7623. $treeBar,
  7624. $color,
  7625. $require['name'],
  7626. $color,
  7627. $require['version'],
  7628. $circularWarn
  7629. ));
  7630. $this->writeTreeLine($info);
  7631. $treeBar = str_replace('â””', ' ', $treeBar);
  7632. $currentTree[] = $require['name'];
  7633. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  7634. }
  7635. }
  7636. }
  7637. protected function addTree(
  7638. $name,
  7639. Link $link,
  7640. InstalledRepository $installedRepo,
  7641. RepositoryInterface $remoteRepos,
  7642. array $packagesInTree
  7643. ) {
  7644. $children = array();
  7645. list($package) = $this->getPackage(
  7646. $installedRepo,
  7647. $remoteRepos,
  7648. $name,
  7649. $link->getPrettyConstraint() === 'self.version' ? $link->getConstraint() : $link->getPrettyConstraint()
  7650. );
  7651. if (is_object($package)) {
  7652. $requires = $package->getRequires();
  7653. ksort($requires);
  7654. foreach ($requires as $requireName => $require) {
  7655. $currentTree = $packagesInTree;
  7656. $treeChildDesc = array(
  7657. 'name' => $requireName,
  7658. 'version' => $require->getPrettyConstraint(),
  7659. );
  7660. if (!in_array($requireName, $currentTree, true)) {
  7661. $currentTree[] = $requireName;
  7662. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  7663. if ($deepChildren) {
  7664. $treeChildDesc['requires'] = $deepChildren;
  7665. }
  7666. }
  7667. $children[] = $treeChildDesc;
  7668. }
  7669. }
  7670. return $children;
  7671. }
  7672. private function updateStatusToVersionStyle($updateStatus)
  7673. {
  7674. return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
  7675. }
  7676. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
  7677. {
  7678. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  7679. return 'up-to-date';
  7680. }
  7681. $constraint = $package->getVersion();
  7682. if (0 !== strpos($constraint, 'dev-')) {
  7683. $constraint = '^'.$constraint;
  7684. }
  7685. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  7686. return 'semver-safe-update';
  7687. }
  7688. return 'update-possible';
  7689. }
  7690. private function writeTreeLine($line)
  7691. {
  7692. $io = $this->getIO();
  7693. if (!$io->isDecorated()) {
  7694. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  7695. }
  7696. $io->write($line);
  7697. }
  7698. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, $minorOnly = false)
  7699. {
  7700. $name = $package->getName();
  7701. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  7702. $stability = $composer->getPackage()->getMinimumStability();
  7703. $flags = $composer->getPackage()->getStabilityFlags();
  7704. if (isset($flags[$name])) {
  7705. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  7706. }
  7707. $bestStability = $stability;
  7708. if ($composer->getPackage()->getPreferStable()) {
  7709. $bestStability = $package->getStability();
  7710. }
  7711. $targetVersion = null;
  7712. if (0 === strpos($package->getVersion(), 'dev-')) {
  7713. $targetVersion = $package->getVersion();
  7714. }
  7715. if ($targetVersion === null && $minorOnly) {
  7716. $targetVersion = '^' . $package->getVersion();
  7717. }
  7718. $candidate = $versionSelector->findBestCandidate($name, $targetVersion, $bestStability);
  7719. while ($candidate instanceof AliasPackage) {
  7720. $candidate = $candidate->getAliasOf();
  7721. }
  7722. return $candidate;
  7723. }
  7724. private function getRepositorySet(Composer $composer)
  7725. {
  7726. if (!$this->repositorySet) {
  7727. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  7728. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  7729. }
  7730. return $this->repositorySet;
  7731. }
  7732. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  7733. {
  7734. $requires = $package->getRequires();
  7735. foreach ($repo->getPackages() as $candidate) {
  7736. foreach ($candidate->getNames() as $name) {
  7737. if (isset($requires[$name])) {
  7738. if (!in_array($candidate, $bucket, true)) {
  7739. $bucket[] = $candidate;
  7740. $bucket = $this->filterRequiredPackages($repo, $candidate, $bucket);
  7741. }
  7742. break;
  7743. }
  7744. }
  7745. }
  7746. return $bucket;
  7747. }
  7748. }
  7749. <?php
  7750. namespace Composer\Command;
  7751. use Symfony\Component\Console\Input\InputInterface;
  7752. use Symfony\Component\Console\Input\InputOption;
  7753. use Symfony\Component\Console\Output\OutputInterface;
  7754. use Composer\Downloader\ChangeReportInterface;
  7755. use Composer\Downloader\DvcsDownloaderInterface;
  7756. use Composer\Downloader\VcsCapableDownloaderInterface;
  7757. use Composer\Package\Dumper\ArrayDumper;
  7758. use Composer\Package\Version\VersionGuesser;
  7759. use Composer\Package\Version\VersionParser;
  7760. use Composer\Plugin\CommandEvent;
  7761. use Composer\Plugin\PluginEvents;
  7762. use Composer\Script\ScriptEvents;
  7763. use Composer\Util\ProcessExecutor;
  7764. class StatusCommand extends BaseCommand
  7765. {
  7766. const EXIT_CODE_ERRORS = 1;
  7767. const EXIT_CODE_UNPUSHED_CHANGES = 2;
  7768. const EXIT_CODE_VERSION_CHANGES = 4;
  7769. protected function configure()
  7770. {
  7771. $this
  7772. ->setName('status')
  7773. ->setDescription('Shows a list of locally modified packages.')
  7774. ->setDefinition(array(
  7775. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  7776. ))
  7777. ->setHelp(
  7778. <<<EOT
  7779. The status command displays a list of dependencies that have
  7780. been modified locally.
  7781. Read more at https://getcomposer.org/doc/03-cli.md#status
  7782. EOT
  7783. )
  7784. ;
  7785. }
  7786. protected function execute(InputInterface $input, OutputInterface $output)
  7787. {
  7788. $composer = $this->getComposer();
  7789. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  7790. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7791. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  7792. $exitCode = $this->doExecute($input);
  7793. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  7794. return $exitCode;
  7795. }
  7796. private function doExecute(InputInterface $input)
  7797. {
  7798. $composer = $this->getComposer();
  7799. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  7800. $dm = $composer->getDownloadManager();
  7801. $im = $composer->getInstallationManager();
  7802. $errors = array();
  7803. $io = $this->getIO();
  7804. $unpushedChanges = array();
  7805. $vcsVersionChanges = array();
  7806. $parser = new VersionParser;
  7807. $guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser);
  7808. $dumper = new ArrayDumper;
  7809. foreach ($installedRepo->getCanonicalPackages() as $package) {
  7810. $downloader = $dm->getDownloaderForPackage($package);
  7811. $targetDir = $im->getInstallPath($package);
  7812. if ($downloader instanceof ChangeReportInterface) {
  7813. if (is_link($targetDir)) {
  7814. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  7815. }
  7816. if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
  7817. $errors[$targetDir] = $changes;
  7818. }
  7819. }
  7820. if ($downloader instanceof VcsCapableDownloaderInterface) {
  7821. if ($downloader->getVcsReference($package, $targetDir)) {
  7822. switch ($package->getInstallationSource()) {
  7823. case 'source':
  7824. $previousRef = $package->getSourceReference();
  7825. break;
  7826. case 'dist':
  7827. $previousRef = $package->getDistReference();
  7828. break;
  7829. default:
  7830. $previousRef = null;
  7831. }
  7832. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  7833. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) {
  7834. $vcsVersionChanges[$targetDir] = array(
  7835. 'previous' => array(
  7836. 'version' => $package->getPrettyVersion(),
  7837. 'ref' => $previousRef,
  7838. ),
  7839. 'current' => array(
  7840. 'version' => $currentVersion['pretty_version'],
  7841. 'ref' => $currentVersion['commit'],
  7842. ),
  7843. );
  7844. }
  7845. }
  7846. }
  7847. if ($downloader instanceof DvcsDownloaderInterface) {
  7848. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  7849. $unpushedChanges[$targetDir] = $unpushed;
  7850. }
  7851. }
  7852. }
  7853. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  7854. $io->writeError('<info>No local changes</info>');
  7855. return 0;
  7856. }
  7857. if ($errors) {
  7858. $io->writeError('<error>You have changes in the following dependencies:</error>');
  7859. foreach ($errors as $path => $changes) {
  7860. if ($input->getOption('verbose')) {
  7861. $indentedChanges = implode("\n", array_map(function ($line) {
  7862. return ' ' . ltrim($line);
  7863. }, explode("\n", $changes)));
  7864. $io->write('<info>'.$path.'</info>:');
  7865. $io->write($indentedChanges);
  7866. } else {
  7867. $io->write($path);
  7868. }
  7869. }
  7870. }
  7871. if ($unpushedChanges) {
  7872. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  7873. foreach ($unpushedChanges as $path => $changes) {
  7874. if ($input->getOption('verbose')) {
  7875. $indentedChanges = implode("\n", array_map(function ($line) {
  7876. return ' ' . ltrim($line);
  7877. }, explode("\n", $changes)));
  7878. $io->write('<info>'.$path.'</info>:');
  7879. $io->write($indentedChanges);
  7880. } else {
  7881. $io->write($path);
  7882. }
  7883. }
  7884. }
  7885. if ($vcsVersionChanges) {
  7886. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  7887. foreach ($vcsVersionChanges as $path => $changes) {
  7888. if ($input->getOption('verbose')) {
  7889. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  7890. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  7891. if ($io->isVeryVerbose()) {
  7892. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  7893. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  7894. }
  7895. $io->write('<info>'.$path.'</info>:');
  7896. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  7897. } else {
  7898. $io->write($path);
  7899. }
  7900. }
  7901. }
  7902. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  7903. $io->writeError('Use --verbose (-v) to see a list of files');
  7904. }
  7905. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  7906. }
  7907. }
  7908. <?php
  7909. namespace Composer\Command;
  7910. use Composer\Repository\PlatformRepository;
  7911. use Composer\Repository\RootPackageRepository;
  7912. use Composer\Repository\InstalledRepository;
  7913. use Composer\Installer\SuggestedPackagesReporter;
  7914. use Symfony\Component\Console\Input\InputArgument;
  7915. use Symfony\Component\Console\Input\InputInterface;
  7916. use Symfony\Component\Console\Input\InputOption;
  7917. use Symfony\Component\Console\Output\OutputInterface;
  7918. class SuggestsCommand extends BaseCommand
  7919. {
  7920. protected function configure()
  7921. {
  7922. $this
  7923. ->setName('suggests')
  7924. ->setDescription('Shows package suggestions.')
  7925. ->setDefinition(array(
  7926. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  7927. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  7928. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  7929. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  7930. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  7931. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
  7932. ))
  7933. ->setHelp(
  7934. <<<EOT
  7935. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  7936. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  7937. EOT
  7938. )
  7939. ;
  7940. }
  7941. protected function execute(InputInterface $input, OutputInterface $output)
  7942. {
  7943. $composer = $this->getComposer();
  7944. $installedRepos = array(
  7945. new RootPackageRepository(clone $composer->getPackage()),
  7946. );
  7947. $locker = $composer->getLocker();
  7948. if ($locker->isLocked()) {
  7949. $installedRepos[] = new PlatformRepository(array(), $locker->getPlatformOverrides());
  7950. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  7951. } else {
  7952. $installedRepos[] = new PlatformRepository(array(), $composer->getConfig()->get('platform') ?: array());
  7953. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  7954. }
  7955. $installedRepo = new InstalledRepository($installedRepos);
  7956. $reporter = new SuggestedPackagesReporter($this->getIO());
  7957. $filter = $input->getArgument('packages');
  7958. $packages = $installedRepo->getPackages();
  7959. $packages[] = $composer->getPackage();
  7960. foreach ($packages as $package) {
  7961. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  7962. continue;
  7963. }
  7964. $reporter->addSuggestionsFromPackage($package);
  7965. }
  7966. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7967. if ($input->getOption('by-suggestion')) {
  7968. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  7969. }
  7970. if ($input->getOption('by-package')) {
  7971. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7972. }
  7973. if ($input->getOption('list')) {
  7974. $mode = SuggestedPackagesReporter::MODE_LIST;
  7975. }
  7976. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  7977. return 0;
  7978. }
  7979. }
  7980. <?php
  7981. namespace Composer\Command;
  7982. use Composer\Composer;
  7983. use Composer\DependencyResolver\Request;
  7984. use Composer\Installer;
  7985. use Composer\IO\IOInterface;
  7986. use Composer\Package\Loader\RootPackageLoader;
  7987. use Composer\Plugin\CommandEvent;
  7988. use Composer\Plugin\PluginEvents;
  7989. use Composer\Package\Version\VersionParser;
  7990. use Composer\Util\HttpDownloader;
  7991. use Composer\Semver\Constraint\MultiConstraint;
  7992. use Composer\Package\Link;
  7993. use Symfony\Component\Console\Helper\Table;
  7994. use Symfony\Component\Console\Input\InputInterface;
  7995. use Symfony\Component\Console\Input\InputOption;
  7996. use Symfony\Component\Console\Input\InputArgument;
  7997. use Symfony\Component\Console\Output\OutputInterface;
  7998. use Symfony\Component\Console\Question\Question;
  7999. class UpdateCommand extends BaseCommand
  8000. {
  8001. protected function configure()
  8002. {
  8003. $this
  8004. ->setName('update')
  8005. ->setAliases(array('u', 'upgrade'))
  8006. ->setDescription('Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
  8007. ->setDefinition(array(
  8008. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
  8009. 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'),
  8010. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  8011. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  8012. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  8013. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  8014. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  8015. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  8016. 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.'),
  8017. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  8018. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  8019. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  8020. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  8021. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  8022. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements.'),
  8023. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements.'),
  8024. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  8025. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  8026. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  8027. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  8028. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  8029. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  8030. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  8031. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  8032. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  8033. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  8034. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  8035. ))
  8036. ->setHelp(
  8037. <<<EOT
  8038. The <info>update</info> command reads the composer.json file from the
  8039. current directory, processes it, and updates, removes or installs all the
  8040. dependencies.
  8041. <info>php composer.phar update</info>
  8042. To limit the update operation to a few packages, you can list the package(s)
  8043. you want to update as such:
  8044. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  8045. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  8046. from a specific vendor:
  8047. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  8048. To run an update with more restrictive constraints you can use:
  8049. <info>php composer.phar update --with vendor/package:1.0.*</info>
  8050. To run a partial update with more restrictive constraints you can use the shorthand:
  8051. <info>php composer.phar update vendor/package:1.0.*</info>
  8052. To select packages names interactively with auto-completion use <info>-i</info>.
  8053. Read more at https://getcomposer.org/doc/03-cli.md#update-u
  8054. EOT
  8055. )
  8056. ;
  8057. }
  8058. protected function execute(InputInterface $input, OutputInterface $output)
  8059. {
  8060. $io = $this->getIO();
  8061. if ($input->getOption('dev')) {
  8062. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  8063. }
  8064. if ($input->getOption('no-suggest')) {
  8065. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  8066. }
  8067. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  8068. $composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
  8069. if (!HttpDownloader::isCurlEnabled()) {
  8070. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  8071. }
  8072. $packages = $input->getArgument('packages');
  8073. $reqs = $this->formatRequirements($input->getOption('with'));
  8074. if ($packages) {
  8075. $allowlistPackagesWithRequirements = array_filter($packages, function ($pkg) {
  8076. return preg_match('{\S+[ =:]\S+}', $pkg) > 0;
  8077. });
  8078. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  8079. $reqs[$package] = $constraint;
  8080. }
  8081. foreach ($allowlistPackagesWithRequirements as $package) {
  8082. $packageName = preg_replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  8083. $index = array_search($package, $packages);
  8084. $packages[$index] = $packageName;
  8085. }
  8086. }
  8087. $rootPackage = $composer->getPackage();
  8088. $rootRequires = $rootPackage->getRequires();
  8089. $rootDevRequires = $rootPackage->getDevRequires();
  8090. foreach ($reqs as $package => $constraint) {
  8091. if (isset($rootRequires[$package])) {
  8092. $rootRequires[$package] = $this->appendConstraintToLink($rootRequires[$package], $constraint);
  8093. } elseif (isset($rootDevRequires[$package])) {
  8094. $rootDevRequires[$package] = $this->appendConstraintToLink($rootDevRequires[$package], $constraint);
  8095. } else {
  8096. throw new \UnexpectedValueException('Only root package requirements can receive temporary constraints and '.$package.' is not one');
  8097. }
  8098. }
  8099. $rootPackage->setRequires($rootRequires);
  8100. $rootPackage->setDevRequires($rootDevRequires);
  8101. $rootPackage->setReferences(RootPackageLoader::extractReferences($reqs, $rootPackage->getReferences()));
  8102. $rootPackage->setStabilityFlags(RootPackageLoader::extractStabilityFlags($reqs, $rootPackage->getMinimumStability(), $rootPackage->getStabilityFlags()));
  8103. if ($input->getOption('interactive')) {
  8104. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  8105. }
  8106. if ($input->getOption('root-reqs')) {
  8107. $requires = array_keys($rootRequires);
  8108. if (!$input->getOption('no-dev')) {
  8109. $requires = array_merge($requires, array_keys($rootDevRequires));
  8110. }
  8111. if (!empty($packages)) {
  8112. $packages = array_intersect($packages, $requires);
  8113. } else {
  8114. $packages = $requires;
  8115. }
  8116. }
  8117. $filteredPackages = array_filter($packages, function ($package) {
  8118. return !in_array($package, array('lock', 'nothing', 'mirrors'), true);
  8119. });
  8120. $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages);
  8121. $packages = $filteredPackages;
  8122. if ($updateMirrors && !empty($packages)) {
  8123. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  8124. return -1;
  8125. }
  8126. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  8127. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  8128. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  8129. $install = Installer::create($io, $composer);
  8130. $config = $composer->getConfig();
  8131. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  8132. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  8133. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  8134. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  8135. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  8136. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  8137. if ($input->getOption('with-all-dependencies')) {
  8138. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  8139. } elseif ($input->getOption('with-dependencies')) {
  8140. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  8141. }
  8142. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  8143. $install
  8144. ->setDryRun($input->getOption('dry-run'))
  8145. ->setVerbose($input->getOption('verbose'))
  8146. ->setPreferSource($preferSource)
  8147. ->setPreferDist($preferDist)
  8148. ->setDevMode(!$input->getOption('no-dev'))
  8149. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  8150. ->setOptimizeAutoloader($optimize)
  8151. ->setClassMapAuthoritative($authoritative)
  8152. ->setApcuAutoloader($apcu, $apcuPrefix)
  8153. ->setUpdate(true)
  8154. ->setInstall(!$input->getOption('no-install'))
  8155. ->setUpdateMirrors($updateMirrors)
  8156. ->setUpdateAllowList($packages)
  8157. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  8158. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  8159. ->setPreferStable($input->getOption('prefer-stable'))
  8160. ->setPreferLowest($input->getOption('prefer-lowest'))
  8161. ;
  8162. if ($input->getOption('no-plugins')) {
  8163. $install->disablePlugins();
  8164. }
  8165. return $install->run();
  8166. }
  8167. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages)
  8168. {
  8169. if (!$input->isInteractive()) {
  8170. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  8171. }
  8172. $requires = array_merge(
  8173. $composer->getPackage()->getRequires(),
  8174. $composer->getPackage()->getDevRequires()
  8175. );
  8176. $autocompleterValues = array();
  8177. foreach ($requires as $require) {
  8178. $target = $require->getTarget();
  8179. $autocompleterValues[strtolower($target)] = $target;
  8180. }
  8181. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  8182. foreach ($installedPackages as $package) {
  8183. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  8184. }
  8185. $helper = $this->getHelper('question');
  8186. $question = new Question('<comment>Enter package name: </comment>', null);
  8187. $io->writeError('<info>Press enter without value to end submission</info>');
  8188. do {
  8189. $autocompleterValues = array_diff($autocompleterValues, $packages);
  8190. $question->setAutocompleterValues($autocompleterValues);
  8191. $addedPackage = $helper->ask($input, $output, $question);
  8192. if (!is_string($addedPackage) || empty($addedPackage)) {
  8193. break;
  8194. }
  8195. $addedPackage = strtolower($addedPackage);
  8196. if (!in_array($addedPackage, $packages)) {
  8197. $packages[] = $addedPackage;
  8198. }
  8199. } while (true);
  8200. $packages = array_filter($packages);
  8201. if (!$packages) {
  8202. throw new \InvalidArgumentException('You must enter minimum one package.');
  8203. }
  8204. $table = new Table($output);
  8205. $table->setHeaders(array('Selected packages'));
  8206. foreach ($packages as $package) {
  8207. $table->addRow(array($package));
  8208. }
  8209. $table->render();
  8210. if ($io->askConfirmation(sprintf(
  8211. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  8212. 1 === count($packages) ? '' : 's'
  8213. ))) {
  8214. return $packages;
  8215. }
  8216. throw new \RuntimeException('Installation aborted.');
  8217. }
  8218. private function appendConstraintToLink(Link $link, $constraint)
  8219. {
  8220. $parser = new VersionParser;
  8221. $oldPrettyString = $link->getConstraint()->getPrettyString();
  8222. $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint)));
  8223. $newConstraint->setPrettyString($oldPrettyString.', '.$constraint);
  8224. return new Link(
  8225. $link->getSource(),
  8226. $link->getTarget(),
  8227. $newConstraint,
  8228. $link->getDescription(),
  8229. $link->getPrettyConstraint() . ', ' . $constraint
  8230. );
  8231. }
  8232. }
  8233. <?php
  8234. namespace Composer\Command;
  8235. use Composer\Factory;
  8236. use Composer\IO\IOInterface;
  8237. use Composer\Package\Loader\ValidatingArrayLoader;
  8238. use Composer\Plugin\CommandEvent;
  8239. use Composer\Plugin\PluginEvents;
  8240. use Composer\Repository\InstalledRepository;
  8241. use Composer\Repository\PlatformRepository;
  8242. use Composer\Util\ConfigValidator;
  8243. use Composer\Util\Filesystem;
  8244. use Symfony\Component\Console\Input\InputArgument;
  8245. use Symfony\Component\Console\Input\InputInterface;
  8246. use Symfony\Component\Console\Input\InputOption;
  8247. use Symfony\Component\Console\Output\OutputInterface;
  8248. class ValidateCommand extends BaseCommand
  8249. {
  8250. protected function configure()
  8251. {
  8252. $this
  8253. ->setName('validate')
  8254. ->setDescription('Validates a composer.json and composer.lock.')
  8255. ->setDefinition(array(
  8256. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  8257. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  8258. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  8259. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  8260. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  8261. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  8262. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  8263. ))
  8264. ->setHelp(
  8265. <<<EOT
  8266. The validate command validates a given composer.json and composer.lock
  8267. Exit codes in case of errors are:
  8268. 1 validation warning(s), only when --strict is given
  8269. 2 validation error(s)
  8270. 3 file unreadable or missing
  8271. Read more at https://getcomposer.org/doc/03-cli.md#validate
  8272. EOT
  8273. );
  8274. }
  8275. protected function execute(InputInterface $input, OutputInterface $output)
  8276. {
  8277. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  8278. $io = $this->getIO();
  8279. if (!file_exists($file)) {
  8280. $io->writeError('<error>' . $file . ' not found.</error>');
  8281. return 3;
  8282. }
  8283. if (!Filesystem::isReadable($file)) {
  8284. $io->writeError('<error>' . $file . ' is not readable.</error>');
  8285. return 3;
  8286. }
  8287. $validator = new ConfigValidator($io);
  8288. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  8289. $checkPublish = !$input->getOption('no-check-publish');
  8290. $checkLock = !$input->getOption('no-check-lock');
  8291. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  8292. $isStrict = $input->getOption('strict');
  8293. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  8294. $lockErrors = array();
  8295. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  8296. $locker = $composer->getLocker();
  8297. if ($locker->isLocked() && !$locker->isFresh()) {
  8298. $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>`.';
  8299. }
  8300. if ($locker->isLocked()) {
  8301. $missingRequirements = false;
  8302. $sets = array(
  8303. array('repo' => $locker->getLockedRepository(false), 'method' => 'getRequires', 'description' => 'Required'),
  8304. array('repo' => $locker->getLockedRepository(true), 'method' => 'getDevRequires', 'description' => 'Required (in require-dev)'),
  8305. );
  8306. foreach ($sets as $set) {
  8307. $installedRepo = new InstalledRepository(array($set['repo']));
  8308. foreach (call_user_func(array($composer->getPackage(), $set['method'])) as $link) {
  8309. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  8310. continue;
  8311. }
  8312. if (!$installedRepo->findPackagesWithReplacersAndProviders($link->getTarget(), $link->getConstraint())) {
  8313. if ($results = $installedRepo->findPackagesWithReplacersAndProviders($link->getTarget())) {
  8314. $provider = reset($results);
  8315. $lockErrors[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is in the lock file as "'.$provider->getPrettyVersion().'" but that does not satisfy your constraint "'.$link->getPrettyConstraint().'".';
  8316. } else {
  8317. $lockErrors[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is not present in the lock file.';
  8318. }
  8319. $missingRequirements = true;
  8320. }
  8321. }
  8322. }
  8323. if ($missingRequirements) {
  8324. $lockErrors[] = 'This usually happens when composer files are incorrectly merged or the composer.json file is manually edited.';
  8325. $lockErrors[] = 'Read more about correctly resolving merge conflicts https://getcomposer.org/doc/articles/resolving-merge-conflicts.md';
  8326. $lockErrors[] = 'and prefer using the "require" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require';
  8327. }
  8328. }
  8329. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  8330. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  8331. if ($input->getOption('with-dependencies')) {
  8332. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  8333. foreach ($localRepo->getPackages() as $package) {
  8334. $path = $composer->getInstallationManager()->getInstallPath($package);
  8335. $file = $path . '/composer.json';
  8336. if (is_dir($path) && file_exists($file)) {
  8337. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  8338. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  8339. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  8340. $exitCode = max($depCode, $exitCode);
  8341. }
  8342. }
  8343. }
  8344. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  8345. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  8346. return max($eventCode, $exitCode);
  8347. }
  8348. private function outputResult(IOInterface $io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false)
  8349. {
  8350. $doPrintSchemaUrl = false;
  8351. if ($errors) {
  8352. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  8353. } elseif ($publishErrors) {
  8354. $io->writeError('<info>' . $name . ' is valid for simple usage with Composer but has</info>');
  8355. $io->writeError('<info>strict errors that make it unable to be published as a package</info>');
  8356. $doPrintSchemaUrl = $printSchemaUrl;
  8357. } elseif ($warnings) {
  8358. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  8359. $doPrintSchemaUrl = $printSchemaUrl;
  8360. } elseif ($lockErrors) {
  8361. $io->write('<info>' . $name . ' is valid but your composer.lock has some '.($checkLock ? 'errors' : 'warnings').'</info>');
  8362. } else {
  8363. $io->write('<info>' . $name . ' is valid</info>');
  8364. }
  8365. if ($doPrintSchemaUrl) {
  8366. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  8367. }
  8368. if ($errors) {
  8369. $errors = array_map(function ($err) {
  8370. return '- ' . $err;
  8371. }, $errors);
  8372. array_unshift($errors, '# General errors');
  8373. }
  8374. if ($warnings) {
  8375. $warnings = array_map(function ($err) {
  8376. return '- ' . $err;
  8377. }, $warnings);
  8378. array_unshift($warnings, '# General warnings');
  8379. }
  8380. $extraWarnings = array();
  8381. if ($publishErrors) {
  8382. $publishErrors = array_map(function ($err) {
  8383. return '- ' . $err;
  8384. }, $publishErrors);
  8385. if ($checkPublish) {
  8386. array_unshift($publishErrors, '# Publish errors');
  8387. $errors = array_merge($errors, $publishErrors);
  8388. } else {
  8389. array_unshift($publishErrors, '# Publish warnings');
  8390. $extraWarnings = array_merge($extraWarnings, $publishErrors);
  8391. }
  8392. }
  8393. if ($lockErrors) {
  8394. if ($checkLock) {
  8395. array_unshift($lockErrors, '# Lock file errors');
  8396. $errors = array_merge($errors, $lockErrors);
  8397. } else {
  8398. array_unshift($lockErrors, '# Lock file warnings');
  8399. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  8400. }
  8401. }
  8402. $messages = array(
  8403. 'error' => $errors,
  8404. 'warning' => array_merge($warnings, $extraWarnings),
  8405. );
  8406. foreach ($messages as $style => $msgs) {
  8407. foreach ($msgs as $msg) {
  8408. if (strpos($msg, '#') === 0) {
  8409. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  8410. } else {
  8411. $io->writeError($msg);
  8412. }
  8413. }
  8414. }
  8415. }
  8416. }
  8417. <?php
  8418. namespace Composer;
  8419. use Composer\Package\RootPackageInterface;
  8420. use Composer\Package\Locker;
  8421. use Composer\Util\Loop;
  8422. use Composer\Repository\RepositoryManager;
  8423. use Composer\Installer\InstallationManager;
  8424. use Composer\Plugin\PluginManager;
  8425. use Composer\Downloader\DownloadManager;
  8426. use Composer\EventDispatcher\EventDispatcher;
  8427. use Composer\Autoload\AutoloadGenerator;
  8428. use Composer\Package\Archiver\ArchiveManager;
  8429. class Composer
  8430. {
  8431. const VERSION = '2.1.14';
  8432. const BRANCH_ALIAS_VERSION = '';
  8433. const RELEASE_DATE = '2021-11-30 10:51:43';
  8434. const SOURCE_VERSION = '';
  8435. const RUNTIME_API_VERSION = '2.1.0';
  8436. public static function getVersion()
  8437. {
  8438. if (self::VERSION === '@package_version'.'@') {
  8439. return self::SOURCE_VERSION;
  8440. }
  8441. if (self::BRANCH_ALIAS_VERSION !== '' && preg_match('{^[a-f0-9]{40}$}', self::VERSION)) {
  8442. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  8443. }
  8444. return self::VERSION;
  8445. }
  8446. private $package;
  8447. private $locker = null;
  8448. private $loop;
  8449. private $repositoryManager;
  8450. private $downloadManager;
  8451. private $installationManager;
  8452. private $pluginManager;
  8453. private $config;
  8454. private $eventDispatcher;
  8455. private $autoloadGenerator;
  8456. private $archiveManager;
  8457. public function setPackage(RootPackageInterface $package)
  8458. {
  8459. $this->package = $package;
  8460. }
  8461. public function getPackage()
  8462. {
  8463. return $this->package;
  8464. }
  8465. public function setConfig(Config $config)
  8466. {
  8467. $this->config = $config;
  8468. }
  8469. public function getConfig()
  8470. {
  8471. return $this->config;
  8472. }
  8473. public function setLocker(Locker $locker)
  8474. {
  8475. $this->locker = $locker;
  8476. }
  8477. public function getLocker()
  8478. {
  8479. return $this->locker;
  8480. }
  8481. public function setLoop(Loop $loop)
  8482. {
  8483. $this->loop = $loop;
  8484. }
  8485. public function getLoop()
  8486. {
  8487. return $this->loop;
  8488. }
  8489. public function setRepositoryManager(RepositoryManager $manager)
  8490. {
  8491. $this->repositoryManager = $manager;
  8492. }
  8493. public function getRepositoryManager()
  8494. {
  8495. return $this->repositoryManager;
  8496. }
  8497. public function setDownloadManager(DownloadManager $manager)
  8498. {
  8499. $this->downloadManager = $manager;
  8500. }
  8501. public function getDownloadManager()
  8502. {
  8503. return $this->downloadManager;
  8504. }
  8505. public function setArchiveManager(ArchiveManager $manager)
  8506. {
  8507. $this->archiveManager = $manager;
  8508. }
  8509. public function getArchiveManager()
  8510. {
  8511. return $this->archiveManager;
  8512. }
  8513. public function setInstallationManager(InstallationManager $manager)
  8514. {
  8515. $this->installationManager = $manager;
  8516. }
  8517. public function getInstallationManager()
  8518. {
  8519. return $this->installationManager;
  8520. }
  8521. public function setPluginManager(PluginManager $manager)
  8522. {
  8523. $this->pluginManager = $manager;
  8524. }
  8525. public function getPluginManager()
  8526. {
  8527. return $this->pluginManager;
  8528. }
  8529. public function setEventDispatcher(EventDispatcher $eventDispatcher)
  8530. {
  8531. $this->eventDispatcher = $eventDispatcher;
  8532. }
  8533. public function getEventDispatcher()
  8534. {
  8535. return $this->eventDispatcher;
  8536. }
  8537. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator)
  8538. {
  8539. $this->autoloadGenerator = $autoloadGenerator;
  8540. }
  8541. public function getAutoloadGenerator()
  8542. {
  8543. return $this->autoloadGenerator;
  8544. }
  8545. }
  8546. <?php
  8547. namespace Composer;
  8548. use Composer\Config\ConfigSourceInterface;
  8549. use Composer\Downloader\TransportException;
  8550. use Composer\IO\IOInterface;
  8551. use Composer\Util\Platform;
  8552. use Composer\Util\ProcessExecutor;
  8553. class Config
  8554. {
  8555. const RELATIVE_PATHS = 1;
  8556. public static $defaultConfig = array(
  8557. 'process-timeout' => 300,
  8558. 'use-include-path' => false,
  8559. 'preferred-install' => 'dist',
  8560. 'notify-on-install' => true,
  8561. 'github-protocols' => array('https', 'ssh', 'git'),
  8562. 'gitlab-protocol' => null,
  8563. 'vendor-dir' => 'vendor',
  8564. 'bin-dir' => '{$vendor-dir}/bin',
  8565. 'cache-dir' => '{$home}/cache',
  8566. 'data-dir' => '{$home}',
  8567. 'cache-files-dir' => '{$cache-dir}/files',
  8568. 'cache-repo-dir' => '{$cache-dir}/repo',
  8569. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  8570. 'cache-ttl' => 15552000,
  8571. 'cache-files-ttl' => null,
  8572. 'cache-files-maxsize' => '300MiB',
  8573. 'cache-read-only' => false,
  8574. 'bin-compat' => 'auto',
  8575. 'discard-changes' => false,
  8576. 'autoloader-suffix' => null,
  8577. 'sort-packages' => false,
  8578. 'optimize-autoloader' => false,
  8579. 'classmap-authoritative' => false,
  8580. 'apcu-autoloader' => false,
  8581. 'prepend-autoloader' => true,
  8582. 'github-domains' => array('github.com'),
  8583. 'bitbucket-expose-hostname' => true,
  8584. 'disable-tls' => false,
  8585. 'secure-http' => true,
  8586. 'secure-svn-domains' => array(),
  8587. 'cafile' => null,
  8588. 'capath' => null,
  8589. 'github-expose-hostname' => true,
  8590. 'gitlab-domains' => array('gitlab.com'),
  8591. 'store-auths' => 'prompt',
  8592. 'platform' => array(),
  8593. 'archive-format' => 'tar',
  8594. 'archive-dir' => '.',
  8595. 'htaccess-protect' => true,
  8596. 'use-github-api' => true,
  8597. 'lock' => true,
  8598. 'platform-check' => 'php-only',
  8599. );
  8600. public static $defaultRepositories = array(
  8601. 'packagist.org' => array(
  8602. 'type' => 'composer',
  8603. 'url' => 'https://repo.packagist.org',
  8604. ),
  8605. );
  8606. private $config;
  8607. private $baseDir;
  8608. private $repositories;
  8609. private $configSource;
  8610. private $authConfigSource;
  8611. private $useEnvironment;
  8612. private $warnedHosts = array();
  8613. public function __construct($useEnvironment = true, $baseDir = null)
  8614. {
  8615. $this->config = static::$defaultConfig;
  8616. $this->repositories = static::$defaultRepositories;
  8617. $this->useEnvironment = (bool) $useEnvironment;
  8618. $this->baseDir = $baseDir;
  8619. }
  8620. public function setConfigSource(ConfigSourceInterface $source)
  8621. {
  8622. $this->configSource = $source;
  8623. }
  8624. public function getConfigSource()
  8625. {
  8626. return $this->configSource;
  8627. }
  8628. public function setAuthConfigSource(ConfigSourceInterface $source)
  8629. {
  8630. $this->authConfigSource = $source;
  8631. }
  8632. public function getAuthConfigSource()
  8633. {
  8634. return $this->authConfigSource;
  8635. }
  8636. public function merge($config)
  8637. {
  8638. if (!empty($config['config']) && is_array($config['config'])) {
  8639. foreach ($config['config'] as $key => $val) {
  8640. if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer')) && isset($this->config[$key])) {
  8641. $this->config[$key] = array_merge($this->config[$key], $val);
  8642. } elseif (in_array($key, array('gitlab-domains', 'github-domains')) && isset($this->config[$key])) {
  8643. $this->config[$key] = array_unique(array_merge($this->config[$key], $val));
  8644. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  8645. if (is_array($val) || is_array($this->config[$key])) {
  8646. if (is_string($val)) {
  8647. $val = array('*' => $val);
  8648. }
  8649. if (is_string($this->config[$key])) {
  8650. $this->config[$key] = array('*' => $this->config[$key]);
  8651. }
  8652. $this->config[$key] = array_merge($this->config[$key], $val);
  8653. if (isset($this->config[$key]['*'])) {
  8654. $wildcard = $this->config[$key]['*'];
  8655. unset($this->config[$key]['*']);
  8656. $this->config[$key]['*'] = $wildcard;
  8657. }
  8658. } else {
  8659. $this->config[$key] = $val;
  8660. }
  8661. } else {
  8662. $this->config[$key] = $val;
  8663. }
  8664. }
  8665. }
  8666. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  8667. $this->repositories = array_reverse($this->repositories, true);
  8668. $newRepos = array_reverse($config['repositories'], true);
  8669. foreach ($newRepos as $name => $repository) {
  8670. if (false === $repository) {
  8671. $this->disableRepoByName((string) $name);
  8672. continue;
  8673. }
  8674. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  8675. $this->disableRepoByName((string) key($repository));
  8676. continue;
  8677. }
  8678. if (isset($repository['type'], $repository['url']) && $repository['type'] === 'composer' && preg_match('{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}', $repository['url'])) {
  8679. $this->disableRepoByName('packagist.org');
  8680. }
  8681. if (is_int($name)) {
  8682. $this->repositories[] = $repository;
  8683. } else {
  8684. if ($name === 'packagist') {
  8685. $this->repositories[$name . '.org'] = $repository;
  8686. } else {
  8687. $this->repositories[$name] = $repository;
  8688. }
  8689. }
  8690. }
  8691. $this->repositories = array_reverse($this->repositories, true);
  8692. }
  8693. }
  8694. public function getRepositories()
  8695. {
  8696. return $this->repositories;
  8697. }
  8698. public function get($key, $flags = 0)
  8699. {
  8700. switch ($key) {
  8701. case 'vendor-dir':
  8702. case 'bin-dir':
  8703. case 'process-timeout':
  8704. case 'data-dir':
  8705. case 'cache-dir':
  8706. case 'cache-files-dir':
  8707. case 'cache-repo-dir':
  8708. case 'cache-vcs-dir':
  8709. case 'cafile':
  8710. case 'capath':
  8711. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  8712. $val = $this->getComposerEnv($env);
  8713. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  8714. $val = Platform::expandPath($val);
  8715. if (substr($key, -4) !== '-dir') {
  8716. return $val;
  8717. }
  8718. return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  8719. case 'cache-read-only':
  8720. case 'htaccess-protect':
  8721. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  8722. $val = $this->getComposerEnv($env);
  8723. if (false === $val) {
  8724. $val = $this->config[$key];
  8725. }
  8726. return $val !== 'false' && (bool) $val;
  8727. case 'disable-tls':
  8728. case 'secure-http':
  8729. case 'use-github-api':
  8730. case 'lock':
  8731. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  8732. return false;
  8733. }
  8734. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  8735. case 'cache-ttl':
  8736. return (int) $this->config[$key];
  8737. case 'cache-files-maxsize':
  8738. if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
  8739. throw new \RuntimeException(
  8740. "Could not parse the value of '$key': {$this->config[$key]}"
  8741. );
  8742. }
  8743. $size = $matches[1];
  8744. if (isset($matches[2])) {
  8745. switch (strtolower($matches[2])) {
  8746. case 'g':
  8747. $size *= 1024;
  8748. case 'm':
  8749. $size *= 1024;
  8750. case 'k':
  8751. $size *= 1024;
  8752. break;
  8753. }
  8754. }
  8755. return $size;
  8756. case 'cache-files-ttl':
  8757. if (isset($this->config[$key])) {
  8758. return (int) $this->config[$key];
  8759. }
  8760. return (int) $this->config['cache-ttl'];
  8761. case 'home':
  8762. $val = preg_replace('#^(\$HOME|~)(/|$)#', rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\') . '/', $this->config[$key]);
  8763. return rtrim($this->process($val, $flags), '/\\');
  8764. case 'bin-compat':
  8765. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  8766. if (!in_array($value, array('auto', 'full', 'symlink'))) {
  8767. throw new \RuntimeException(
  8768. "Invalid value for 'bin-compat': {$value}. Expected auto, full or symlink"
  8769. );
  8770. }
  8771. return $value;
  8772. case 'discard-changes':
  8773. if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
  8774. if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) {
  8775. throw new \RuntimeException(
  8776. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  8777. );
  8778. }
  8779. if ('stash' === $env) {
  8780. return 'stash';
  8781. }
  8782. return $env !== 'false' && (bool) $env;
  8783. }
  8784. if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
  8785. throw new \RuntimeException(
  8786. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  8787. );
  8788. }
  8789. return $this->config[$key];
  8790. case 'github-protocols':
  8791. $protos = $this->config['github-protocols'];
  8792. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  8793. unset($protos[$index]);
  8794. }
  8795. if (reset($protos) === 'http') {
  8796. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  8797. }
  8798. return $protos;
  8799. default:
  8800. if (!isset($this->config[$key])) {
  8801. return null;
  8802. }
  8803. return $this->process($this->config[$key], $flags);
  8804. }
  8805. }
  8806. public function all($flags = 0)
  8807. {
  8808. $all = array(
  8809. 'repositories' => $this->getRepositories(),
  8810. );
  8811. foreach (array_keys($this->config) as $key) {
  8812. $all['config'][$key] = $this->get($key, $flags);
  8813. }
  8814. return $all;
  8815. }
  8816. public function raw()
  8817. {
  8818. return array(
  8819. 'repositories' => $this->getRepositories(),
  8820. 'config' => $this->config,
  8821. );
  8822. }
  8823. public function has($key)
  8824. {
  8825. return array_key_exists($key, $this->config);
  8826. }
  8827. private function process($value, $flags)
  8828. {
  8829. $config = $this;
  8830. if (!is_string($value)) {
  8831. return $value;
  8832. }
  8833. return preg_replace_callback('#\{\$(.+)\}#', function ($match) use ($config, $flags) {
  8834. return $config->get($match[1], $flags);
  8835. }, $value);
  8836. }
  8837. private function realpath($path)
  8838. {
  8839. if (preg_match('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
  8840. return $path;
  8841. }
  8842. return $this->baseDir . '/' . $path;
  8843. }
  8844. private function getComposerEnv($var)
  8845. {
  8846. if ($this->useEnvironment) {
  8847. return getenv($var);
  8848. }
  8849. return false;
  8850. }
  8851. private function disableRepoByName($name)
  8852. {
  8853. if (isset($this->repositories[$name])) {
  8854. unset($this->repositories[$name]);
  8855. } elseif ($name === 'packagist') {
  8856. unset($this->repositories['packagist.org']);
  8857. }
  8858. }
  8859. public function prohibitUrlByConfig($url, IOInterface $io = null)
  8860. {
  8861. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  8862. return;
  8863. }
  8864. $scheme = parse_url($url, PHP_URL_SCHEME);
  8865. $hostname = parse_url($url, PHP_URL_HOST);
  8866. if (in_array($scheme, array('http', 'git', 'ftp', 'svn'))) {
  8867. if ($this->get('secure-http')) {
  8868. if ($scheme === 'svn') {
  8869. if (in_array($hostname, $this->get('secure-svn-domains'), true)) {
  8870. return;
  8871. }
  8872. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-svn-domains for details.");
  8873. }
  8874. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  8875. }
  8876. if ($io) {
  8877. $host = parse_url($url, PHP_URL_HOST);
  8878. if (!isset($this->warnedHosts[$host])) {
  8879. $io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
  8880. }
  8881. $this->warnedHosts[$host] = true;
  8882. }
  8883. }
  8884. }
  8885. public static function disableProcessTimeout()
  8886. {
  8887. ProcessExecutor::setTimeout(0);
  8888. }
  8889. }
  8890. <?php
  8891. namespace Composer\Config;
  8892. interface ConfigSourceInterface
  8893. {
  8894. public function addRepository($name, $config, $append = true);
  8895. public function removeRepository($name);
  8896. public function addConfigSetting($name, $value);
  8897. public function removeConfigSetting($name);
  8898. public function addProperty($name, $value);
  8899. public function removeProperty($name);
  8900. public function addLink($type, $name, $value);
  8901. public function removeLink($type, $name);
  8902. public function getName();
  8903. }
  8904. <?php
  8905. namespace Composer\Config;
  8906. use Composer\Json\JsonFile;
  8907. use Composer\Json\JsonManipulator;
  8908. use Composer\Json\JsonValidationException;
  8909. use Composer\Util\Filesystem;
  8910. use Composer\Util\Silencer;
  8911. class JsonConfigSource implements ConfigSourceInterface
  8912. {
  8913. private $file;
  8914. private $authConfig;
  8915. public function __construct(JsonFile $file, $authConfig = false)
  8916. {
  8917. $this->file = $file;
  8918. $this->authConfig = $authConfig;
  8919. }
  8920. public function getName()
  8921. {
  8922. return $this->file->getPath();
  8923. }
  8924. public function addRepository($name, $config, $append = true)
  8925. {
  8926. $this->manipulateJson('addRepository', $name, $config, $append, function (&$config, $repo, $repoConfig) use ($append) {
  8927. if (isset($config['repositories'])) {
  8928. foreach ($config['repositories'] as $index => $val) {
  8929. if ($index === $repo) {
  8930. continue;
  8931. }
  8932. if (is_numeric($index) && ($val === array('packagist' => false) || $val === array('packagist.org' => false))) {
  8933. unset($config['repositories'][$index]);
  8934. $config['repositories']['packagist.org'] = false;
  8935. break;
  8936. }
  8937. }
  8938. }
  8939. if ($append) {
  8940. $config['repositories'][$repo] = $repoConfig;
  8941. } else {
  8942. $config['repositories'] = array($repo => $repoConfig) + $config['repositories'];
  8943. }
  8944. });
  8945. }
  8946. public function removeRepository($name)
  8947. {
  8948. $this->manipulateJson('removeRepository', $name, function (&$config, $repo) {
  8949. unset($config['repositories'][$repo]);
  8950. });
  8951. }
  8952. public function addConfigSetting($name, $value)
  8953. {
  8954. $authConfig = $this->authConfig;
  8955. $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
  8956. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8957. list($key, $host) = explode('.', $key, 2);
  8958. if ($authConfig) {
  8959. $config[$key][$host] = $val;
  8960. } else {
  8961. $config['config'][$key][$host] = $val;
  8962. }
  8963. } else {
  8964. $config['config'][$key] = $val;
  8965. }
  8966. });
  8967. }
  8968. public function removeConfigSetting($name)
  8969. {
  8970. $authConfig = $this->authConfig;
  8971. $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
  8972. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8973. list($key, $host) = explode('.', $key, 2);
  8974. if ($authConfig) {
  8975. unset($config[$key][$host]);
  8976. } else {
  8977. unset($config['config'][$key][$host]);
  8978. }
  8979. } else {
  8980. unset($config['config'][$key]);
  8981. }
  8982. });
  8983. }
  8984. public function addProperty($name, $value)
  8985. {
  8986. $this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
  8987. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8988. $bits = explode('.', $key);
  8989. $last = array_pop($bits);
  8990. $arr = &$config[reset($bits)];
  8991. foreach ($bits as $bit) {
  8992. if (!isset($arr[$bit])) {
  8993. $arr[$bit] = array();
  8994. }
  8995. $arr = &$arr[$bit];
  8996. }
  8997. $arr[$last] = $val;
  8998. } else {
  8999. $config[$key] = $val;
  9000. }
  9001. });
  9002. }
  9003. public function removeProperty($name)
  9004. {
  9005. $this->manipulateJson('removeProperty', $name, function (&$config, $key) {
  9006. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  9007. $bits = explode('.', $key);
  9008. $last = array_pop($bits);
  9009. $arr = &$config[reset($bits)];
  9010. foreach ($bits as $bit) {
  9011. if (!isset($arr[$bit])) {
  9012. return;
  9013. }
  9014. $arr = &$arr[$bit];
  9015. }
  9016. unset($arr[$last]);
  9017. } else {
  9018. unset($config[$key]);
  9019. }
  9020. });
  9021. }
  9022. public function addLink($type, $name, $value)
  9023. {
  9024. $this->manipulateJson('addLink', $type, $name, $value, function (&$config, $type, $name, $value) {
  9025. $config[$type][$name] = $value;
  9026. });
  9027. }
  9028. public function removeLink($type, $name)
  9029. {
  9030. $this->manipulateJson('removeSubNode', $type, $name, function (&$config, $type, $name) {
  9031. unset($config[$type][$name]);
  9032. });
  9033. $this->manipulateJson('removeMainKeyIfEmpty', $type, function (&$config, $type) {
  9034. if (0 === count($config[$type])) {
  9035. unset($config[$type]);
  9036. }
  9037. });
  9038. }
  9039. protected function manipulateJson($method, $args, $fallback)
  9040. {
  9041. $args = func_get_args();
  9042. array_shift($args);
  9043. $fallback = array_pop($args);
  9044. if ($this->file->exists()) {
  9045. if (!is_writable($this->file->getPath())) {
  9046. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  9047. }
  9048. if (!Filesystem::isReadable($this->file->getPath())) {
  9049. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  9050. }
  9051. $contents = file_get_contents($this->file->getPath());
  9052. } elseif ($this->authConfig) {
  9053. $contents = "{\n}\n";
  9054. } else {
  9055. $contents = "{\n \"config\": {\n }\n}\n";
  9056. }
  9057. $manipulator = new JsonManipulator($contents);
  9058. $newFile = !$this->file->exists();
  9059. if ($this->authConfig && $method === 'addConfigSetting') {
  9060. $method = 'addSubNode';
  9061. list($mainNode, $name) = explode('.', $args[0], 2);
  9062. $args = array($mainNode, $name, $args[1]);
  9063. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  9064. $method = 'removeSubNode';
  9065. list($mainNode, $name) = explode('.', $args[0], 2);
  9066. $args = array($mainNode, $name);
  9067. }
  9068. if (call_user_func_array(array($manipulator, $method), $args)) {
  9069. file_put_contents($this->file->getPath(), $manipulator->getContents());
  9070. } else {
  9071. $config = $this->file->read();
  9072. $this->arrayUnshiftRef($args, $config);
  9073. call_user_func_array($fallback, $args);
  9074. foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'support') as $prop) {
  9075. if (isset($config[$prop]) && $config[$prop] === array()) {
  9076. $config[$prop] = new \stdClass;
  9077. }
  9078. }
  9079. foreach (array('psr-0', 'psr-4') as $prop) {
  9080. if (isset($config['autoload'][$prop]) && $config['autoload'][$prop] === array()) {
  9081. $config['autoload'][$prop] = new \stdClass;
  9082. }
  9083. if (isset($config['autoload-dev'][$prop]) && $config['autoload-dev'][$prop] === array()) {
  9084. $config['autoload-dev'][$prop] = new \stdClass;
  9085. }
  9086. }
  9087. foreach (array('platform', 'http-basic', 'bearer', 'gitlab-token', 'gitlab-oauth', 'github-oauth', 'preferred-install') as $prop) {
  9088. if (isset($config['config'][$prop]) && $config['config'][$prop] === array()) {
  9089. $config['config'][$prop] = new \stdClass;
  9090. }
  9091. }
  9092. $this->file->write($config);
  9093. }
  9094. try {
  9095. $this->file->validateSchema(JsonFile::LAX_SCHEMA);
  9096. } catch (JsonValidationException $e) {
  9097. file_put_contents($this->file->getPath(), $contents);
  9098. throw new \RuntimeException('Failed to update composer.json with a valid format, reverting to the original content. Please report an issue to us with details (command you run and a copy of your composer.json).', 0, $e);
  9099. }
  9100. if ($newFile) {
  9101. Silencer::call('chmod', $this->file->getPath(), 0600);
  9102. }
  9103. }
  9104. private function arrayUnshiftRef(&$array, &$value)
  9105. {
  9106. $return = array_unshift($array, '');
  9107. $array[0] = &$value;
  9108. return $return;
  9109. }
  9110. }
  9111. <?php
  9112. namespace Composer\Console;
  9113. use Composer\IO\NullIO;
  9114. use Composer\Util\Filesystem;
  9115. use Composer\Util\Platform;
  9116. use Composer\Util\Silencer;
  9117. use Symfony\Component\Console\Application as BaseApplication;
  9118. use Symfony\Component\Console\Exception\CommandNotFoundException;
  9119. use Symfony\Component\Console\Helper\HelperSet;
  9120. use Symfony\Component\Console\Helper\QuestionHelper;
  9121. use Symfony\Component\Console\Input\InputInterface;
  9122. use Symfony\Component\Console\Input\InputOption;
  9123. use Symfony\Component\Console\Output\OutputInterface;
  9124. use Seld\JsonLint\ParsingException;
  9125. use Composer\Command;
  9126. use Composer\Composer;
  9127. use Composer\Factory;
  9128. use Composer\IO\IOInterface;
  9129. use Composer\IO\ConsoleIO;
  9130. use Composer\Json\JsonValidationException;
  9131. use Composer\Util\ErrorHandler;
  9132. use Composer\Util\HttpDownloader;
  9133. use Composer\EventDispatcher\ScriptExecutionException;
  9134. use Composer\Exception\NoSslException;
  9135. use Composer\XdebugHandler\XdebugHandler;
  9136. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  9137. class Application extends BaseApplication
  9138. {
  9139. protected $composer;
  9140. protected $io;
  9141. private static $logo = ' ______
  9142. / ____/___ ____ ___ ____ ____ ________ _____
  9143. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  9144. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  9145. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  9146. /_/
  9147. ';
  9148. private $hasPluginCommands = false;
  9149. private $disablePluginsByDefault = false;
  9150. private $initialWorkingDirectory;
  9151. public function __construct()
  9152. {
  9153. static $shutdownRegistered = false;
  9154. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  9155. ini_set('xdebug.show_exception_trace', '0');
  9156. ini_set('xdebug.scream', '0');
  9157. }
  9158. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  9159. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  9160. }
  9161. if (!$shutdownRegistered) {
  9162. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  9163. pcntl_async_signals(true);
  9164. pcntl_signal(SIGINT, function ($sig) {
  9165. exit(130);
  9166. });
  9167. }
  9168. $shutdownRegistered = true;
  9169. register_shutdown_function(function () {
  9170. $lastError = error_get_last();
  9171. if ($lastError && $lastError['message'] &&
  9172. (strpos($lastError['message'], 'Allowed memory') !== false ||
  9173. strpos($lastError['message'], 'exceeded memory') !== false )) {
  9174. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  9175. }
  9176. });
  9177. }
  9178. $this->io = new NullIO();
  9179. $this->initialWorkingDirectory = getcwd();
  9180. parent::__construct('Composer', Composer::getVersion());
  9181. }
  9182. public function run(InputInterface $input = null, OutputInterface $output = null)
  9183. {
  9184. if (null === $output) {
  9185. $output = Factory::createOutput();
  9186. }
  9187. return parent::run($input, $output);
  9188. }
  9189. public function doRun(InputInterface $input, OutputInterface $output)
  9190. {
  9191. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  9192. if (getenv('COMPOSER_NO_INTERACTION') || !Platform::isTty(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'))) {
  9193. $input->setInteractive(false);
  9194. }
  9195. $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array(
  9196. new QuestionHelper(),
  9197. )));
  9198. ErrorHandler::register($io);
  9199. if ($input->hasParameterOption('--no-cache')) {
  9200. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  9201. Platform::putEnv('COMPOSER_CACHE_DIR', Platform::isWindows() ? 'nul' : '/dev/null');
  9202. }
  9203. if ($newWorkDir = $this->getNewWorkingDir($input)) {
  9204. $oldWorkingDir = getcwd();
  9205. chdir($newWorkDir);
  9206. $this->initialWorkingDirectory = $newWorkDir;
  9207. $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
  9208. }
  9209. $commandName = '';
  9210. if ($name = $this->getCommandName($input)) {
  9211. try {
  9212. $commandName = $this->find($name)->getName();
  9213. } catch (CommandNotFoundException $e) {
  9214. $commandName = false;
  9215. } catch (\InvalidArgumentException $e) {
  9216. }
  9217. }
  9218. if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile())) {
  9219. $dir = dirname(getcwd());
  9220. $home = realpath(getenv('HOME') ?: getenv('USERPROFILE') ?: '/');
  9221. while (dirname($dir) !== $dir && $dir !== $home) {
  9222. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  9223. if ($io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ')) {
  9224. $oldWorkingDir = getcwd();
  9225. chdir($dir);
  9226. }
  9227. break;
  9228. }
  9229. $dir = dirname($dir);
  9230. }
  9231. }
  9232. $mayNeedPluginCommand = false === $input->hasParameterOption(array('--version', '-V'))
  9233. && (
  9234. false === $commandName
  9235. || in_array($commandName, array('', 'list', 'help'), true)
  9236. );
  9237. if ($mayNeedPluginCommand && !$this->disablePluginsByDefault && !$this->hasPluginCommands) {
  9238. try {
  9239. foreach ($this->getPluginCommands() as $command) {
  9240. if ($this->has($command->getName())) {
  9241. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  9242. } else {
  9243. $this->add($command);
  9244. }
  9245. }
  9246. } catch (NoSslException $e) {
  9247. } catch (ParsingException $e) {
  9248. $details = $e->getDetails();
  9249. $file = realpath(Factory::getComposerFile());
  9250. $line = null;
  9251. if ($details && isset($details['line'])) {
  9252. $line = $details['line'];
  9253. }
  9254. $ghe = new GithubActionError($this->io);
  9255. $ghe->emit($e->getMessage(), $file, $line);
  9256. throw $e;
  9257. }
  9258. $this->hasPluginCommands = true;
  9259. }
  9260. $isProxyCommand = false;
  9261. if ($name = $this->getCommandName($input)) {
  9262. try {
  9263. $command = $this->find($name);
  9264. $commandName = $command->getName();
  9265. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  9266. } catch (\InvalidArgumentException $e) {
  9267. }
  9268. }
  9269. if (!$isProxyCommand) {
  9270. $io->writeError(sprintf(
  9271. 'Running %s (%s) with %s on %s',
  9272. Composer::getVersion(),
  9273. Composer::RELEASE_DATE,
  9274. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  9275. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  9276. ), true, IOInterface::DEBUG);
  9277. if (PHP_VERSION_ID < 50302) {
  9278. $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>');
  9279. }
  9280. if (XdebugHandler::isXdebugActive() && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  9281. $io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>');
  9282. }
  9283. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  9284. $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']));
  9285. }
  9286. if (
  9287. !Platform::isWindows()
  9288. && function_exists('exec')
  9289. && !getenv('COMPOSER_ALLOW_SUPERUSER')
  9290. && (ini_get('open_basedir') || !file_exists('/.dockerenv'))
  9291. ) {
  9292. if (function_exists('posix_getuid') && posix_getuid() === 0) {
  9293. if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
  9294. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  9295. if ($io->isInteractive()) {
  9296. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  9297. return 1;
  9298. }
  9299. }
  9300. }
  9301. if ($uid = (int) getenv('SUDO_UID')) {
  9302. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  9303. }
  9304. }
  9305. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  9306. }
  9307. Silencer::call(function () use ($io) {
  9308. $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
  9309. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  9310. $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()));
  9311. }
  9312. });
  9313. $file = Factory::getComposerFile();
  9314. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  9315. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  9316. foreach ($composer['scripts'] as $script => $dummy) {
  9317. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  9318. if ($this->has($script)) {
  9319. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  9320. } else {
  9321. $description = null;
  9322. if (isset($composer['scripts-descriptions'][$script])) {
  9323. $description = $composer['scripts-descriptions'][$script];
  9324. }
  9325. $this->add(new Command\ScriptAliasCommand($script, $description));
  9326. }
  9327. }
  9328. }
  9329. }
  9330. }
  9331. }
  9332. try {
  9333. if ($input->hasParameterOption('--profile')) {
  9334. $startTime = microtime(true);
  9335. $this->io->enableDebugging($startTime);
  9336. }
  9337. $result = parent::doRun($input, $output);
  9338. if (isset($oldWorkingDir)) {
  9339. Silencer::call('chdir', $oldWorkingDir);
  9340. }
  9341. if (isset($startTime)) {
  9342. $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');
  9343. }
  9344. restore_error_handler();
  9345. return $result;
  9346. } catch (ScriptExecutionException $e) {
  9347. return (int) $e->getCode();
  9348. } catch (\Exception $e) {
  9349. $ghe = new GithubActionError($this->io);
  9350. $ghe->emit($e->getMessage());
  9351. $this->hintCommonErrors($e);
  9352. restore_error_handler();
  9353. throw $e;
  9354. }
  9355. }
  9356. private function getNewWorkingDir(InputInterface $input)
  9357. {
  9358. $workingDir = $input->getParameterOption(array('--working-dir', '-d'));
  9359. if (false !== $workingDir && !is_dir($workingDir)) {
  9360. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  9361. }
  9362. return $workingDir;
  9363. }
  9364. private function hintCommonErrors(\Exception $exception)
  9365. {
  9366. $io = $this->getIO();
  9367. Silencer::suppress();
  9368. try {
  9369. $composer = $this->getComposer(false, true);
  9370. if ($composer) {
  9371. $config = $composer->getConfig();
  9372. $minSpaceFree = 1024 * 1024;
  9373. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  9374. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  9375. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  9376. ) {
  9377. $io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  9378. }
  9379. }
  9380. } catch (\Exception $e) {
  9381. }
  9382. Silencer::restore();
  9383. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  9384. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  9385. $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);
  9386. }
  9387. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  9388. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  9389. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  9390. }
  9391. if ($exception instanceof ProcessTimedOutException) {
  9392. $io->writeError('<error>The following exception is caused by a process timeout</error>', true, IOInterface::QUIET);
  9393. $io->writeError('<error>Check https://getcomposer.org/doc/06-config.md#process-timeout for details</error>', true, IOInterface::QUIET);
  9394. }
  9395. if ($hints = HttpDownloader::getExceptionHints($exception)) {
  9396. foreach ($hints as $hint) {
  9397. $io->writeError($hint, true, IOInterface::QUIET);
  9398. }
  9399. }
  9400. }
  9401. public function getComposer($required = true, $disablePlugins = null)
  9402. {
  9403. if (null === $disablePlugins) {
  9404. $disablePlugins = $this->disablePluginsByDefault;
  9405. }
  9406. if (null === $this->composer) {
  9407. try {
  9408. $this->composer = Factory::create($this->io, null, $disablePlugins);
  9409. } catch (\InvalidArgumentException $e) {
  9410. if ($required) {
  9411. $this->io->writeError($e->getMessage());
  9412. if (!method_exists($this, 'areExceptionsCaught') || $this->areExceptionsCaught()) {
  9413. exit(1);
  9414. }
  9415. throw $e;
  9416. }
  9417. } catch (JsonValidationException $e) {
  9418. if ($required) {
  9419. throw $e;
  9420. }
  9421. }
  9422. }
  9423. return $this->composer;
  9424. }
  9425. public function resetComposer()
  9426. {
  9427. $this->composer = null;
  9428. if (method_exists($this->getIO(), 'resetAuthentications')) {
  9429. $this->getIO()->resetAuthentications();
  9430. }
  9431. }
  9432. public function getIO()
  9433. {
  9434. return $this->io;
  9435. }
  9436. public function getHelp()
  9437. {
  9438. return self::$logo . parent::getHelp();
  9439. }
  9440. protected function getDefaultCommands()
  9441. {
  9442. $commands = array_merge(parent::getDefaultCommands(), array(
  9443. new Command\AboutCommand(),
  9444. new Command\ConfigCommand(),
  9445. new Command\DependsCommand(),
  9446. new Command\ProhibitsCommand(),
  9447. new Command\InitCommand(),
  9448. new Command\InstallCommand(),
  9449. new Command\CreateProjectCommand(),
  9450. new Command\UpdateCommand(),
  9451. new Command\SearchCommand(),
  9452. new Command\ValidateCommand(),
  9453. new Command\ShowCommand(),
  9454. new Command\SuggestsCommand(),
  9455. new Command\RequireCommand(),
  9456. new Command\DumpAutoloadCommand(),
  9457. new Command\StatusCommand(),
  9458. new Command\ArchiveCommand(),
  9459. new Command\DiagnoseCommand(),
  9460. new Command\RunScriptCommand(),
  9461. new Command\LicensesCommand(),
  9462. new Command\GlobalCommand(),
  9463. new Command\ClearCacheCommand(),
  9464. new Command\RemoveCommand(),
  9465. new Command\HomeCommand(),
  9466. new Command\ExecCommand(),
  9467. new Command\OutdatedCommand(),
  9468. new Command\CheckPlatformReqsCommand(),
  9469. new Command\FundCommand(),
  9470. new Command\ReinstallCommand(),
  9471. ));
  9472. if (strpos(__FILE__, 'phar:') === 0) {
  9473. $commands[] = new Command\SelfUpdateCommand();
  9474. }
  9475. return $commands;
  9476. }
  9477. public function getLongVersion()
  9478. {
  9479. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  9480. return sprintf(
  9481. '<info>%s</info> version <comment>%s (%s)</comment> %s',
  9482. $this->getName(),
  9483. Composer::BRANCH_ALIAS_VERSION,
  9484. $this->getVersion(),
  9485. Composer::RELEASE_DATE
  9486. );
  9487. }
  9488. return parent::getLongVersion() . ' ' . Composer::RELEASE_DATE;
  9489. }
  9490. protected function getDefaultInputDefinition()
  9491. {
  9492. $definition = parent::getDefaultInputDefinition();
  9493. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  9494. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  9495. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  9496. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  9497. return $definition;
  9498. }
  9499. private function getPluginCommands()
  9500. {
  9501. $commands = array();
  9502. $composer = $this->getComposer(false, false);
  9503. if (null === $composer) {
  9504. $composer = Factory::createGlobal($this->io);
  9505. }
  9506. if (null !== $composer) {
  9507. $pm = $composer->getPluginManager();
  9508. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
  9509. $newCommands = $capability->getCommands();
  9510. if (!is_array($newCommands)) {
  9511. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  9512. }
  9513. foreach ($newCommands as $command) {
  9514. if (!$command instanceof Command\BaseCommand) {
  9515. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  9516. }
  9517. }
  9518. $commands = array_merge($commands, $newCommands);
  9519. }
  9520. }
  9521. return $commands;
  9522. }
  9523. public function getInitialWorkingDirectory()
  9524. {
  9525. return $this->initialWorkingDirectory;
  9526. }
  9527. }
  9528. <?php
  9529. namespace Composer\Console;
  9530. use Composer\IO\IOInterface;
  9531. final class GithubActionError
  9532. {
  9533. protected $io;
  9534. public function __construct(IOInterface $io)
  9535. {
  9536. $this->io = $io;
  9537. }
  9538. public function emit($message, $file = null, $line = null)
  9539. {
  9540. if (getenv('GITHUB_ACTIONS') && !getenv('COMPOSER_TESTS_ARE_RUNNING')) {
  9541. $message = $this->escapeData($message);
  9542. if ($file && $line) {
  9543. $file = $this->escapeProperty($file);
  9544. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  9545. } elseif ($file) {
  9546. $file = $this->escapeProperty($file);
  9547. $this->io->write("::error file=". $file ."::". $message);
  9548. } else {
  9549. $this->io->write("::error ::". $message);
  9550. }
  9551. }
  9552. }
  9553. private function escapeData($data) {
  9554. $data = str_replace("%", '%25', $data);
  9555. $data = str_replace("\r", '%0D', $data);
  9556. $data = str_replace("\n", '%0A', $data);
  9557. return $data;
  9558. }
  9559. private function escapeProperty($property) {
  9560. $property = str_replace("%", '%25', $property);
  9561. $property = str_replace("\r", '%0D', $property);
  9562. $property = str_replace("\n", '%0A', $property);
  9563. $property = str_replace(":", '%3A', $property);
  9564. $property = str_replace(",", '%2C', $property);
  9565. return $property;
  9566. }
  9567. }
  9568. <?php
  9569. namespace Composer\Console;
  9570. use Symfony\Component\Console\Formatter\OutputFormatter;
  9571. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  9572. class HtmlOutputFormatter extends OutputFormatter
  9573. {
  9574. private static $availableForegroundColors = array(
  9575. 30 => 'black',
  9576. 31 => 'red',
  9577. 32 => 'green',
  9578. 33 => 'yellow',
  9579. 34 => 'blue',
  9580. 35 => 'magenta',
  9581. 36 => 'cyan',
  9582. 37 => 'white',
  9583. );
  9584. private static $availableBackgroundColors = array(
  9585. 40 => 'black',
  9586. 41 => 'red',
  9587. 42 => 'green',
  9588. 43 => 'yellow',
  9589. 44 => 'blue',
  9590. 45 => 'magenta',
  9591. 46 => 'cyan',
  9592. 47 => 'white',
  9593. );
  9594. private static $availableOptions = array(
  9595. 1 => 'bold',
  9596. 4 => 'underscore',
  9597. );
  9598. public function __construct(array $styles = array())
  9599. {
  9600. parent::__construct(true, $styles);
  9601. }
  9602. public function format($message)
  9603. {
  9604. $formatted = parent::format($message);
  9605. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  9606. return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
  9607. }
  9608. private function formatHtml($matches)
  9609. {
  9610. $out = '<span style="';
  9611. foreach (explode(';', $matches[1]) as $code) {
  9612. if (isset(self::$availableForegroundColors[$code])) {
  9613. $out .= 'color:'.self::$availableForegroundColors[$code].';';
  9614. } elseif (isset(self::$availableBackgroundColors[$code])) {
  9615. $out .= 'background-color:'.self::$availableBackgroundColors[$code].';';
  9616. } elseif (isset(self::$availableOptions[$code])) {
  9617. switch (self::$availableOptions[$code]) {
  9618. case 'bold':
  9619. $out .= 'font-weight:bold;';
  9620. break;
  9621. case 'underscore':
  9622. $out .= 'text-decoration:underline;';
  9623. break;
  9624. }
  9625. }
  9626. }
  9627. return $out.'">'.$matches[2].'</span>';
  9628. }
  9629. }
  9630. <?php
  9631. namespace Composer\DependencyResolver;
  9632. class Decisions implements \Iterator, \Countable
  9633. {
  9634. const DECISION_LITERAL = 0;
  9635. const DECISION_REASON = 1;
  9636. protected $pool;
  9637. protected $decisionMap;
  9638. protected $decisionQueue = array();
  9639. public function __construct(Pool $pool)
  9640. {
  9641. $this->pool = $pool;
  9642. $this->decisionMap = array();
  9643. }
  9644. public function decide($literal, $level, Rule $why)
  9645. {
  9646. $this->addDecision($literal, $level);
  9647. $this->decisionQueue[] = array(
  9648. self::DECISION_LITERAL => $literal,
  9649. self::DECISION_REASON => $why,
  9650. );
  9651. }
  9652. public function satisfy($literal)
  9653. {
  9654. $packageId = abs($literal);
  9655. return (
  9656. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  9657. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  9658. );
  9659. }
  9660. public function conflict($literal)
  9661. {
  9662. $packageId = abs($literal);
  9663. return (
  9664. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  9665. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  9666. );
  9667. }
  9668. public function decided($literalOrPackageId)
  9669. {
  9670. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  9671. }
  9672. public function undecided($literalOrPackageId)
  9673. {
  9674. return empty($this->decisionMap[abs($literalOrPackageId)]);
  9675. }
  9676. public function decidedInstall($literalOrPackageId)
  9677. {
  9678. $packageId = abs($literalOrPackageId);
  9679. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  9680. }
  9681. public function decisionLevel($literalOrPackageId)
  9682. {
  9683. $packageId = abs($literalOrPackageId);
  9684. if (isset($this->decisionMap[$packageId])) {
  9685. return abs($this->decisionMap[$packageId]);
  9686. }
  9687. return 0;
  9688. }
  9689. public function decisionRule($literalOrPackageId)
  9690. {
  9691. $packageId = abs($literalOrPackageId);
  9692. foreach ($this->decisionQueue as $decision) {
  9693. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  9694. return $decision[self::DECISION_REASON];
  9695. }
  9696. }
  9697. return null;
  9698. }
  9699. public function atOffset($queueOffset)
  9700. {
  9701. return $this->decisionQueue[$queueOffset];
  9702. }
  9703. public function validOffset($queueOffset)
  9704. {
  9705. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  9706. }
  9707. public function lastReason()
  9708. {
  9709. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  9710. }
  9711. public function lastLiteral()
  9712. {
  9713. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  9714. }
  9715. public function reset()
  9716. {
  9717. while ($decision = array_pop($this->decisionQueue)) {
  9718. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  9719. }
  9720. }
  9721. public function resetToOffset($offset)
  9722. {
  9723. while (\count($this->decisionQueue) > $offset + 1) {
  9724. $decision = array_pop($this->decisionQueue);
  9725. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  9726. }
  9727. }
  9728. public function revertLast()
  9729. {
  9730. $this->decisionMap[abs($this->lastLiteral())] = 0;
  9731. array_pop($this->decisionQueue);
  9732. }
  9733. #[\ReturnTypeWillChange]
  9734. public function count()
  9735. {
  9736. return \count($this->decisionQueue);
  9737. }
  9738. #[\ReturnTypeWillChange]
  9739. public function rewind()
  9740. {
  9741. end($this->decisionQueue);
  9742. }
  9743. #[\ReturnTypeWillChange]
  9744. public function current()
  9745. {
  9746. return current($this->decisionQueue);
  9747. }
  9748. #[\ReturnTypeWillChange]
  9749. public function key()
  9750. {
  9751. return key($this->decisionQueue);
  9752. }
  9753. #[\ReturnTypeWillChange]
  9754. public function next()
  9755. {
  9756. prev($this->decisionQueue);
  9757. }
  9758. #[\ReturnTypeWillChange]
  9759. public function valid()
  9760. {
  9761. return false !== current($this->decisionQueue);
  9762. }
  9763. public function isEmpty()
  9764. {
  9765. return \count($this->decisionQueue) === 0;
  9766. }
  9767. protected function addDecision($literal, $level)
  9768. {
  9769. $packageId = abs($literal);
  9770. $previousDecision = isset($this->decisionMap[$packageId]) ? $this->decisionMap[$packageId] : null;
  9771. if ($previousDecision != 0) {
  9772. $literalString = $this->pool->literalToPrettyString($literal, array());
  9773. $package = $this->pool->literalToPackage($literal);
  9774. throw new SolverBugException(
  9775. "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."."
  9776. );
  9777. }
  9778. if ($literal > 0) {
  9779. $this->decisionMap[$packageId] = $level;
  9780. } else {
  9781. $this->decisionMap[$packageId] = -$level;
  9782. }
  9783. }
  9784. public function toString(Pool $pool = null)
  9785. {
  9786. $decisionMap = $this->decisionMap;
  9787. ksort($decisionMap);
  9788. $str = '[';
  9789. foreach ($decisionMap as $packageId => $level) {
  9790. $str .= (($pool) ? $pool->literalToPackage($packageId) : $packageId).':'.$level.',';
  9791. }
  9792. $str .= ']';
  9793. return $str;
  9794. }
  9795. public function __toString()
  9796. {
  9797. return $this->toString();
  9798. }
  9799. }
  9800. <?php
  9801. namespace Composer\DependencyResolver;
  9802. use Composer\Package\AliasPackage;
  9803. use Composer\Package\BasePackage;
  9804. use Composer\Package\PackageInterface;
  9805. use Composer\Semver\Constraint\Constraint;
  9806. class DefaultPolicy implements PolicyInterface
  9807. {
  9808. private $preferStable;
  9809. private $preferLowest;
  9810. public function __construct($preferStable = false, $preferLowest = false)
  9811. {
  9812. $this->preferStable = $preferStable;
  9813. $this->preferLowest = $preferLowest;
  9814. }
  9815. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
  9816. {
  9817. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  9818. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  9819. }
  9820. $constraint = new Constraint($operator, $b->getVersion());
  9821. $version = new Constraint('==', $a->getVersion());
  9822. return $constraint->matchSpecific($version, true);
  9823. }
  9824. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null)
  9825. {
  9826. $packages = $this->groupLiteralsByName($pool, $literals);
  9827. $policy = $this;
  9828. foreach ($packages as &$nameLiterals) {
  9829. usort($nameLiterals, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  9830. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  9831. });
  9832. }
  9833. foreach ($packages as &$sortedLiterals) {
  9834. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  9835. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  9836. }
  9837. $selected = \call_user_func_array('array_merge', array_values($packages));
  9838. usort($selected, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  9839. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  9840. });
  9841. return $selected;
  9842. }
  9843. protected function groupLiteralsByName(Pool $pool, $literals)
  9844. {
  9845. $packages = array();
  9846. foreach ($literals as $literal) {
  9847. $packageName = $pool->literalToPackage($literal)->getName();
  9848. if (!isset($packages[$packageName])) {
  9849. $packages[$packageName] = array();
  9850. }
  9851. $packages[$packageName][] = $literal;
  9852. }
  9853. return $packages;
  9854. }
  9855. public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, $requiredPackage = null, $ignoreReplace = false)
  9856. {
  9857. if ($a->getName() === $b->getName()) {
  9858. $aAliased = $a instanceof AliasPackage;
  9859. $bAliased = $b instanceof AliasPackage;
  9860. if ($aAliased && !$bAliased) {
  9861. return -1;
  9862. }
  9863. if (!$aAliased && $bAliased) {
  9864. return 1;
  9865. }
  9866. }
  9867. if (!$ignoreReplace) {
  9868. if ($this->replaces($a, $b)) {
  9869. return 1;
  9870. }
  9871. if ($this->replaces($b, $a)) {
  9872. return -1;
  9873. }
  9874. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  9875. $requiredVendor = substr($requiredPackage, 0, $pos);
  9876. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  9877. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  9878. if ($bIsSameVendor !== $aIsSameVendor) {
  9879. return $aIsSameVendor ? -1 : 1;
  9880. }
  9881. }
  9882. }
  9883. if ($a->id === $b->id) {
  9884. return 0;
  9885. }
  9886. return ($a->id < $b->id) ? -1 : 1;
  9887. }
  9888. protected function replaces(BasePackage $source, BasePackage $target)
  9889. {
  9890. foreach ($source->getReplaces() as $link) {
  9891. if ($link->getTarget() === $target->getName()
  9892. ) {
  9893. return true;
  9894. }
  9895. }
  9896. return false;
  9897. }
  9898. protected function pruneToBestVersion(Pool $pool, $literals)
  9899. {
  9900. $operator = $this->preferLowest ? '<' : '>';
  9901. $bestLiterals = array($literals[0]);
  9902. $bestPackage = $pool->literalToPackage($literals[0]);
  9903. foreach ($literals as $i => $literal) {
  9904. if (0 === $i) {
  9905. continue;
  9906. }
  9907. $package = $pool->literalToPackage($literal);
  9908. if ($this->versionCompare($package, $bestPackage, $operator)) {
  9909. $bestPackage = $package;
  9910. $bestLiterals = array($literal);
  9911. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  9912. $bestLiterals[] = $literal;
  9913. }
  9914. }
  9915. return $bestLiterals;
  9916. }
  9917. protected function pruneRemoteAliases(Pool $pool, array $literals)
  9918. {
  9919. $hasLocalAlias = false;
  9920. foreach ($literals as $literal) {
  9921. $package = $pool->literalToPackage($literal);
  9922. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9923. $hasLocalAlias = true;
  9924. break;
  9925. }
  9926. }
  9927. if (!$hasLocalAlias) {
  9928. return $literals;
  9929. }
  9930. $selected = array();
  9931. foreach ($literals as $literal) {
  9932. $package = $pool->literalToPackage($literal);
  9933. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9934. $selected[] = $literal;
  9935. }
  9936. }
  9937. return $selected;
  9938. }
  9939. }
  9940. <?php
  9941. namespace Composer\DependencyResolver;
  9942. class GenericRule extends Rule
  9943. {
  9944. protected $literals;
  9945. public function __construct(array $literals, $reason, $reasonData)
  9946. {
  9947. parent::__construct($reason, $reasonData);
  9948. sort($literals);
  9949. $this->literals = $literals;
  9950. }
  9951. public function getLiterals()
  9952. {
  9953. return $this->literals;
  9954. }
  9955. public function getHash()
  9956. {
  9957. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  9958. return $data['hash'];
  9959. }
  9960. public function equals(Rule $rule)
  9961. {
  9962. return $this->literals === $rule->getLiterals();
  9963. }
  9964. public function isAssertion()
  9965. {
  9966. return 1 === \count($this->literals);
  9967. }
  9968. public function __toString()
  9969. {
  9970. $result = $this->isDisabled() ? 'disabled(' : '(';
  9971. foreach ($this->literals as $i => $literal) {
  9972. if ($i != 0) {
  9973. $result .= '|';
  9974. }
  9975. $result .= $literal;
  9976. }
  9977. $result .= ')';
  9978. return $result;
  9979. }
  9980. }
  9981. <?php
  9982. namespace Composer\DependencyResolver;
  9983. use Composer\Repository\InstalledRepositoryInterface;
  9984. use Composer\Repository\RepositoryInterface;
  9985. class LocalRepoTransaction extends Transaction
  9986. {
  9987. public function __construct(RepositoryInterface $lockedRepository, InstalledRepositoryInterface $localRepository)
  9988. {
  9989. parent::__construct(
  9990. $localRepository->getPackages(),
  9991. $lockedRepository->getPackages()
  9992. );
  9993. }
  9994. }
  9995. <?php
  9996. namespace Composer\DependencyResolver;
  9997. use Composer\Package\AliasPackage;
  9998. use Composer\Package\BasePackage;
  9999. use Composer\Package\Package;
  10000. class LockTransaction extends Transaction
  10001. {
  10002. protected $presentMap;
  10003. protected $unlockableMap;
  10004. protected $resultPackages;
  10005. public function __construct(Pool $pool, array $presentMap, array $unlockableMap, Decisions $decisions)
  10006. {
  10007. $this->presentMap = $presentMap;
  10008. $this->unlockableMap = $unlockableMap;
  10009. $this->setResultPackages($pool, $decisions);
  10010. parent::__construct($this->presentMap, $this->resultPackages['all']);
  10011. }
  10012. public function setResultPackages(Pool $pool, Decisions $decisions)
  10013. {
  10014. $this->resultPackages = array('all' => array(), 'non-dev' => array(), 'dev' => array());
  10015. foreach ($decisions as $i => $decision) {
  10016. $literal = $decision[Decisions::DECISION_LITERAL];
  10017. if ($literal > 0) {
  10018. $package = $pool->literalToPackage($literal);
  10019. $this->resultPackages['all'][] = $package;
  10020. if (!isset($this->unlockableMap[$package->id])) {
  10021. $this->resultPackages['non-dev'][] = $package;
  10022. }
  10023. }
  10024. }
  10025. }
  10026. public function setNonDevPackages(LockTransaction $extractionResult)
  10027. {
  10028. $packages = $extractionResult->getNewLockPackages(false);
  10029. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  10030. $this->resultPackages['non-dev'] = array();
  10031. foreach ($packages as $package) {
  10032. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  10033. if ($package->getName() == $resultPackage->getName()) {
  10034. $this->resultPackages['non-dev'][] = $resultPackage;
  10035. unset($this->resultPackages['dev'][$i]);
  10036. }
  10037. }
  10038. }
  10039. }
  10040. public function getNewLockPackages($devMode, $updateMirrors = false)
  10041. {
  10042. $packages = array();
  10043. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  10044. if (!$package instanceof AliasPackage) {
  10045. if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
  10046. foreach ($this->presentMap as $presentPackage) {
  10047. if ($package->getName() == $presentPackage->getName() && $package->getVersion() == $presentPackage->getVersion()) {
  10048. if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) {
  10049. $package->setSourceDistReferences($presentPackage->getSourceReference());
  10050. }
  10051. if ($presentPackage->getReleaseDate() && $package instanceof Package) {
  10052. $package->setReleaseDate($presentPackage->getReleaseDate());
  10053. }
  10054. }
  10055. }
  10056. }
  10057. $packages[] = $package;
  10058. }
  10059. }
  10060. return $packages;
  10061. }
  10062. public function getAliases($aliases)
  10063. {
  10064. $usedAliases = array();
  10065. foreach ($this->resultPackages['all'] as $package) {
  10066. if ($package instanceof AliasPackage) {
  10067. foreach ($aliases as $index => $alias) {
  10068. if ($alias['package'] === $package->getName()) {
  10069. $usedAliases[] = $alias;
  10070. unset($aliases[$index]);
  10071. }
  10072. }
  10073. }
  10074. }
  10075. usort($usedAliases, function ($a, $b) {
  10076. return strcmp($a['package'], $b['package']);
  10077. });
  10078. return $usedAliases;
  10079. }
  10080. }
  10081. <?php
  10082. namespace Composer\DependencyResolver;
  10083. class MultiConflictRule extends Rule
  10084. {
  10085. protected $literals;
  10086. public function __construct(array $literals, $reason, $reasonData)
  10087. {
  10088. parent::__construct($reason, $reasonData);
  10089. if (\count($literals) < 3) {
  10090. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  10091. }
  10092. sort($literals);
  10093. $this->literals = $literals;
  10094. }
  10095. public function getLiterals()
  10096. {
  10097. return $this->literals;
  10098. }
  10099. public function getHash()
  10100. {
  10101. $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));
  10102. return $data['hash'];
  10103. }
  10104. public function equals(Rule $rule)
  10105. {
  10106. if ($rule instanceof MultiConflictRule) {
  10107. return $this->literals === $rule->getLiterals();
  10108. }
  10109. return false;
  10110. }
  10111. public function isAssertion()
  10112. {
  10113. return false;
  10114. }
  10115. public function disable()
  10116. {
  10117. 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.");
  10118. }
  10119. public function __toString()
  10120. {
  10121. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  10122. foreach ($this->literals as $i => $literal) {
  10123. if ($i != 0) {
  10124. $result .= '|';
  10125. }
  10126. $result .= $literal;
  10127. }
  10128. $result .= '))';
  10129. return $result;
  10130. }
  10131. }
  10132. <?php
  10133. namespace Composer\DependencyResolver\Operation;
  10134. use Composer\Package\PackageInterface;
  10135. class InstallOperation extends SolverOperation implements OperationInterface
  10136. {
  10137. const TYPE = 'install';
  10138. protected $package;
  10139. public function __construct(PackageInterface $package)
  10140. {
  10141. $this->package = $package;
  10142. }
  10143. public function getPackage()
  10144. {
  10145. return $this->package;
  10146. }
  10147. public function show($lock)
  10148. {
  10149. return self::format($this->package, $lock);
  10150. }
  10151. public static function format(PackageInterface $package, $lock = false)
  10152. {
  10153. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  10154. }
  10155. }
  10156. <?php
  10157. namespace Composer\DependencyResolver\Operation;
  10158. use Composer\Package\AliasPackage;
  10159. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  10160. {
  10161. const TYPE = 'markAliasInstalled';
  10162. protected $package;
  10163. public function __construct(AliasPackage $package)
  10164. {
  10165. $this->package = $package;
  10166. }
  10167. public function getPackage()
  10168. {
  10169. return $this->package;
  10170. }
  10171. public function show($lock)
  10172. {
  10173. 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>)';
  10174. }
  10175. }
  10176. <?php
  10177. namespace Composer\DependencyResolver\Operation;
  10178. use Composer\Package\AliasPackage;
  10179. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  10180. {
  10181. const TYPE = 'markAliasUninstalled';
  10182. protected $package;
  10183. public function __construct(AliasPackage $package)
  10184. {
  10185. $this->package = $package;
  10186. }
  10187. public function getPackage()
  10188. {
  10189. return $this->package;
  10190. }
  10191. public function show($lock)
  10192. {
  10193. 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>)';
  10194. }
  10195. }
  10196. <?php
  10197. namespace Composer\DependencyResolver\Operation;
  10198. interface OperationInterface
  10199. {
  10200. public function getOperationType();
  10201. public function show($lock);
  10202. public function __toString();
  10203. }
  10204. <?php
  10205. namespace Composer\DependencyResolver\Operation;
  10206. abstract class SolverOperation implements OperationInterface
  10207. {
  10208. const TYPE = null;
  10209. public function getOperationType()
  10210. {
  10211. return static::TYPE;
  10212. }
  10213. public function __toString()
  10214. {
  10215. return $this->show(false);
  10216. }
  10217. }
  10218. <?php
  10219. namespace Composer\DependencyResolver\Operation;
  10220. use Composer\Package\PackageInterface;
  10221. class UninstallOperation extends SolverOperation implements OperationInterface
  10222. {
  10223. const TYPE = 'uninstall';
  10224. protected $package;
  10225. public function __construct(PackageInterface $package)
  10226. {
  10227. $this->package = $package;
  10228. }
  10229. public function getPackage()
  10230. {
  10231. return $this->package;
  10232. }
  10233. public function show($lock)
  10234. {
  10235. return self::format($this->package, $lock);
  10236. }
  10237. public static function format(PackageInterface $package, $lock = false)
  10238. {
  10239. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  10240. }
  10241. }
  10242. <?php
  10243. namespace Composer\DependencyResolver\Operation;
  10244. use Composer\Package\PackageInterface;
  10245. use Composer\Package\Version\VersionParser;
  10246. class UpdateOperation extends SolverOperation implements OperationInterface
  10247. {
  10248. const TYPE = 'update';
  10249. protected $initialPackage;
  10250. protected $targetPackage;
  10251. public function __construct(PackageInterface $initial, PackageInterface $target)
  10252. {
  10253. $this->initialPackage = $initial;
  10254. $this->targetPackage = $target;
  10255. }
  10256. public function getInitialPackage()
  10257. {
  10258. return $this->initialPackage;
  10259. }
  10260. public function getTargetPackage()
  10261. {
  10262. return $this->targetPackage;
  10263. }
  10264. public function show($lock)
  10265. {
  10266. return self::format($this->initialPackage, $this->targetPackage, $lock);
  10267. }
  10268. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)
  10269. {
  10270. $fromVersion = $initialPackage->getFullPrettyVersion();
  10271. $toVersion = $targetPackage->getFullPrettyVersion();
  10272. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  10273. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  10274. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  10275. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  10276. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  10277. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  10278. }
  10279. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  10280. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  10281. }
  10282. }
  10283. <?php
  10284. namespace Composer\DependencyResolver;
  10285. use Composer\Package\PackageInterface;
  10286. use Composer\Semver\Constraint\Constraint;
  10287. interface PolicyInterface
  10288. {
  10289. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
  10290. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
  10291. }
  10292. <?php
  10293. namespace Composer\DependencyResolver;
  10294. use Composer\Package\BasePackage;
  10295. use Composer\Package\Version\VersionParser;
  10296. use Composer\Semver\CompilingMatcher;
  10297. use Composer\Semver\Constraint\ConstraintInterface;
  10298. use Composer\Semver\Constraint\Constraint;
  10299. class Pool implements \Countable
  10300. {
  10301. protected $packages = array();
  10302. protected $packageByName = array();
  10303. protected $versionParser;
  10304. protected $providerCache = array();
  10305. protected $unacceptableFixedOrLockedPackages;
  10306. public function __construct(array $packages = array(), array $unacceptableFixedOrLockedPackages = array())
  10307. {
  10308. $this->versionParser = new VersionParser;
  10309. $this->setPackages($packages);
  10310. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  10311. }
  10312. private function setPackages(array $packages)
  10313. {
  10314. $id = 1;
  10315. foreach ($packages as $package) {
  10316. $this->packages[] = $package;
  10317. $package->id = $id++;
  10318. foreach ($package->getNames() as $provided) {
  10319. $this->packageByName[$provided][] = $package;
  10320. }
  10321. }
  10322. }
  10323. public function getPackages()
  10324. {
  10325. return $this->packages;
  10326. }
  10327. public function packageById($id)
  10328. {
  10329. return $this->packages[$id - 1];
  10330. }
  10331. #[\ReturnTypeWillChange]
  10332. public function count()
  10333. {
  10334. return \count($this->packages);
  10335. }
  10336. public function whatProvides($name, ConstraintInterface $constraint = null)
  10337. {
  10338. $key = (string) $constraint;
  10339. if (isset($this->providerCache[$name][$key])) {
  10340. return $this->providerCache[$name][$key];
  10341. }
  10342. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  10343. }
  10344. private function computeWhatProvides($name, ConstraintInterface $constraint = null)
  10345. {
  10346. if (!isset($this->packageByName[$name])) {
  10347. return array();
  10348. }
  10349. $matches = array();
  10350. foreach ($this->packageByName[$name] as $candidate) {
  10351. if ($this->match($candidate, $name, $constraint)) {
  10352. $matches[] = $candidate;
  10353. }
  10354. }
  10355. return $matches;
  10356. }
  10357. public function literalToPackage($literal)
  10358. {
  10359. $packageId = abs($literal);
  10360. return $this->packageById($packageId);
  10361. }
  10362. public function literalToPrettyString($literal, $installedMap)
  10363. {
  10364. $package = $this->literalToPackage($literal);
  10365. if (isset($installedMap[$package->id])) {
  10366. $prefix = ($literal > 0 ? 'keep' : 'remove');
  10367. } else {
  10368. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  10369. }
  10370. return $prefix.' '.$package->getPrettyString();
  10371. }
  10372. public function match(BasePackage $candidate, $name, ConstraintInterface $constraint = null)
  10373. {
  10374. $candidateName = $candidate->getName();
  10375. $candidateVersion = $candidate->getVersion();
  10376. if ($candidateName === $name) {
  10377. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  10378. }
  10379. $provides = $candidate->getProvides();
  10380. $replaces = $candidate->getReplaces();
  10381. if (isset($replaces[0]) || isset($provides[0])) {
  10382. foreach ($provides as $link) {
  10383. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  10384. return true;
  10385. }
  10386. }
  10387. foreach ($replaces as $link) {
  10388. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  10389. return true;
  10390. }
  10391. }
  10392. return false;
  10393. }
  10394. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  10395. return true;
  10396. }
  10397. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  10398. return true;
  10399. }
  10400. return false;
  10401. }
  10402. public function isUnacceptableFixedOrLockedPackage(BasePackage $package)
  10403. {
  10404. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  10405. }
  10406. public function __toString()
  10407. {
  10408. $str = "Pool:\n";
  10409. foreach ($this->packages as $package) {
  10410. $str .= '- '.str_pad((string) $package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  10411. }
  10412. return $str;
  10413. }
  10414. }
  10415. <?php
  10416. namespace Composer\DependencyResolver;
  10417. use Composer\EventDispatcher\EventDispatcher;
  10418. use Composer\IO\IOInterface;
  10419. use Composer\Package\AliasPackage;
  10420. use Composer\Package\BasePackage;
  10421. use Composer\Package\CompleteAliasPackage;
  10422. use Composer\Package\CompletePackage;
  10423. use Composer\Package\PackageInterface;
  10424. use Composer\Package\Version\StabilityFilter;
  10425. use Composer\Plugin\PluginEvents;
  10426. use Composer\Plugin\PrePoolCreateEvent;
  10427. use Composer\Repository\PlatformRepository;
  10428. use Composer\Repository\RepositoryInterface;
  10429. use Composer\Repository\RootPackageRepository;
  10430. use Composer\Semver\CompilingMatcher;
  10431. use Composer\Semver\Constraint\Constraint;
  10432. use Composer\Semver\Constraint\ConstraintInterface;
  10433. use Composer\Semver\Constraint\MatchAllConstraint;
  10434. use Composer\Semver\Constraint\MultiConstraint;
  10435. use Composer\Semver\Intervals;
  10436. class PoolBuilder
  10437. {
  10438. private $acceptableStabilities;
  10439. private $stabilityFlags;
  10440. private $rootAliases;
  10441. private $rootReferences;
  10442. private $eventDispatcher;
  10443. private $io;
  10444. private $aliasMap = array();
  10445. private $packagesToLoad = array();
  10446. private $loadedPackages = array();
  10447. private $loadedPerRepo = array();
  10448. private $packages = array();
  10449. private $unacceptableFixedOrLockedPackages = array();
  10450. private $updateAllowList = array();
  10451. private $skippedLoad = array();
  10452. private $maxExtendedReqs = array();
  10453. private $updateAllowWarned = array();
  10454. private $indexCounter = 0;
  10455. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, EventDispatcher $eventDispatcher = null)
  10456. {
  10457. $this->acceptableStabilities = $acceptableStabilities;
  10458. $this->stabilityFlags = $stabilityFlags;
  10459. $this->rootAliases = $rootAliases;
  10460. $this->rootReferences = $rootReferences;
  10461. $this->eventDispatcher = $eventDispatcher;
  10462. $this->io = $io;
  10463. }
  10464. public function buildPool(array $repositories, Request $request)
  10465. {
  10466. if ($request->getUpdateAllowList()) {
  10467. $this->updateAllowList = $request->getUpdateAllowList();
  10468. $this->warnAboutNonMatchingUpdateAllowList($request);
  10469. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  10470. if (!$this->isUpdateAllowed($lockedPackage)) {
  10471. $request->lockPackage($lockedPackage);
  10472. $lockedName = $lockedPackage->getName();
  10473. $this->skippedLoad[$lockedName] = $lockedName;
  10474. foreach ($lockedPackage->getReplaces() as $link) {
  10475. $this->skippedLoad[$link->getTarget()] = $lockedName;
  10476. }
  10477. }
  10478. }
  10479. }
  10480. foreach ($request->getFixedOrLockedPackages() as $package) {
  10481. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  10482. foreach ($package->getReplaces() as $link) {
  10483. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  10484. }
  10485. if (
  10486. $package->getRepository() instanceof RootPackageRepository
  10487. || $package->getRepository() instanceof PlatformRepository
  10488. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  10489. ) {
  10490. $this->loadPackage($request, $package, false);
  10491. } else {
  10492. $this->unacceptableFixedOrLockedPackages[] = $package;
  10493. }
  10494. }
  10495. foreach ($request->getRequires() as $packageName => $constraint) {
  10496. if (isset($this->loadedPackages[$packageName])) {
  10497. continue;
  10498. }
  10499. $this->packagesToLoad[$packageName] = $constraint;
  10500. $this->maxExtendedReqs[$packageName] = true;
  10501. }
  10502. foreach ($this->packagesToLoad as $name => $constraint) {
  10503. if (isset($this->loadedPackages[$name])) {
  10504. unset($this->packagesToLoad[$name]);
  10505. }
  10506. }
  10507. while (!empty($this->packagesToLoad)) {
  10508. $this->loadPackagesMarkedForLoading($request, $repositories);
  10509. }
  10510. foreach ($this->packages as $i => $package) {
  10511. if (!$package instanceof AliasPackage) {
  10512. $constraint = new Constraint('==', $package->getVersion());
  10513. $aliasedPackages = array($i => $package);
  10514. if (isset($this->aliasMap[spl_object_hash($package)])) {
  10515. $aliasedPackages += $this->aliasMap[spl_object_hash($package)];
  10516. }
  10517. $found = false;
  10518. foreach ($aliasedPackages as $packageOrAlias) {
  10519. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  10520. $found = true;
  10521. }
  10522. }
  10523. if (!$found) {
  10524. foreach ($aliasedPackages as $index => $packageOrAlias) {
  10525. unset($this->packages[$index]);
  10526. }
  10527. }
  10528. }
  10529. }
  10530. if ($this->eventDispatcher) {
  10531. $prePoolCreateEvent = new PrePoolCreateEvent(
  10532. PluginEvents::PRE_POOL_CREATE,
  10533. $repositories,
  10534. $request,
  10535. $this->acceptableStabilities,
  10536. $this->stabilityFlags,
  10537. $this->rootAliases,
  10538. $this->rootReferences,
  10539. $this->packages,
  10540. $this->unacceptableFixedOrLockedPackages
  10541. );
  10542. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  10543. $this->packages = $prePoolCreateEvent->getPackages();
  10544. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  10545. }
  10546. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  10547. $this->aliasMap = array();
  10548. $this->packagesToLoad = array();
  10549. $this->loadedPackages = array();
  10550. $this->loadedPerRepo = array();
  10551. $this->packages = array();
  10552. $this->unacceptableFixedOrLockedPackages = array();
  10553. $this->maxExtendedReqs = array();
  10554. $this->skippedLoad = array();
  10555. $this->indexCounter = 0;
  10556. Intervals::clear();
  10557. return $pool;
  10558. }
  10559. private function markPackageNameForLoading(Request $request, $name, ConstraintInterface $constraint)
  10560. {
  10561. if (PlatformRepository::isPlatformPackage($name)) {
  10562. return;
  10563. }
  10564. if (isset($this->maxExtendedReqs[$name])) {
  10565. return;
  10566. }
  10567. $rootRequires = $request->getRequires();
  10568. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  10569. $constraint = $rootRequires[$name];
  10570. }
  10571. if (!isset($this->loadedPackages[$name])) {
  10572. if (isset($this->packagesToLoad[$name])) {
  10573. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  10574. return;
  10575. }
  10576. $constraint = Intervals::compactConstraint(MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false));
  10577. }
  10578. $this->packagesToLoad[$name] = $constraint;
  10579. return;
  10580. }
  10581. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  10582. return;
  10583. }
  10584. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false));
  10585. unset($this->loadedPackages[$name]);
  10586. }
  10587. private function loadPackagesMarkedForLoading(Request $request, $repositories)
  10588. {
  10589. foreach ($this->packagesToLoad as $name => $constraint) {
  10590. $this->loadedPackages[$name] = $constraint;
  10591. }
  10592. $packageBatch = $this->packagesToLoad;
  10593. $this->packagesToLoad = array();
  10594. foreach ($repositories as $repoIndex => $repository) {
  10595. if (empty($packageBatch)) {
  10596. break;
  10597. }
  10598. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  10599. continue;
  10600. }
  10601. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, isset($this->loadedPerRepo[$repoIndex]) ? $this->loadedPerRepo[$repoIndex] : array());
  10602. foreach ($result['namesFound'] as $name) {
  10603. unset($packageBatch[$name]);
  10604. }
  10605. foreach ($result['packages'] as $package) {
  10606. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  10607. $this->loadPackage($request, $package);
  10608. }
  10609. }
  10610. }
  10611. private function loadPackage(Request $request, BasePackage $package, $propagateUpdate = true)
  10612. {
  10613. $index = $this->indexCounter++;
  10614. $this->packages[$index] = $package;
  10615. if ($package instanceof AliasPackage) {
  10616. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  10617. }
  10618. $name = $package->getName();
  10619. if (isset($this->rootReferences[$name])) {
  10620. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  10621. $package->setSourceDistReferences($this->rootReferences[$name]);
  10622. }
  10623. }
  10624. if ($propagateUpdate && isset($this->rootAliases[$name][$package->getVersion()])) {
  10625. $alias = $this->rootAliases[$name][$package->getVersion()];
  10626. if ($package instanceof AliasPackage) {
  10627. $basePackage = $package->getAliasOf();
  10628. } else {
  10629. $basePackage = $package;
  10630. }
  10631. if ($basePackage instanceof CompletePackage) {
  10632. $aliasPackage = new CompleteAliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  10633. } else {
  10634. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  10635. }
  10636. $aliasPackage->setRootPackageAlias(true);
  10637. $newIndex = $this->indexCounter++;
  10638. $this->packages[$newIndex] = $aliasPackage;
  10639. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  10640. }
  10641. foreach ($package->getRequires() as $link) {
  10642. $require = $link->getTarget();
  10643. $linkConstraint = $link->getConstraint();
  10644. if (isset($this->skippedLoad[$require])) {
  10645. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  10646. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$require])) {
  10647. $this->unlockPackage($request, $require);
  10648. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  10649. } elseif (!isset($this->updateAllowWarned[$this->skippedLoad[$require]])) {
  10650. $this->updateAllowWarned[$this->skippedLoad[$require]] = true;
  10651. $this->io->writeError('<warning>Dependency "'.$this->skippedLoad[$require].'" is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.</warning>');
  10652. }
  10653. }
  10654. } else {
  10655. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  10656. }
  10657. }
  10658. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  10659. foreach ($package->getReplaces() as $link) {
  10660. $replace = $link->getTarget();
  10661. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  10662. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) {
  10663. $this->unlockPackage($request, $replace);
  10664. $this->markPackageNameForLoading($request, $replace, $link->getConstraint());
  10665. } elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $replace) && !isset($this->updateAllowWarned[$replace])) {
  10666. $this->updateAllowWarned[$replace] = true;
  10667. $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>');
  10668. }
  10669. }
  10670. }
  10671. }
  10672. }
  10673. private function isRootRequire(Request $request, $name)
  10674. {
  10675. $rootRequires = $request->getRequires();
  10676. return isset($rootRequires[$name]);
  10677. }
  10678. private function isUpdateAllowed(BasePackage $package)
  10679. {
  10680. if ($package->getDistType() === 'path') {
  10681. $transportOptions = $package->getTransportOptions();
  10682. if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
  10683. return true;
  10684. }
  10685. }
  10686. foreach ($this->updateAllowList as $pattern => $void) {
  10687. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  10688. if (preg_match($patternRegexp, $package->getName())) {
  10689. return true;
  10690. }
  10691. }
  10692. return false;
  10693. }
  10694. private function warnAboutNonMatchingUpdateAllowList(Request $request)
  10695. {
  10696. foreach ($this->updateAllowList as $pattern => $void) {
  10697. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  10698. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10699. if (preg_match($patternRegexp, $package->getName())) {
  10700. continue 2;
  10701. }
  10702. }
  10703. foreach ($request->getRequires() as $packageName => $constraint) {
  10704. if (preg_match($patternRegexp, $packageName)) {
  10705. continue 2;
  10706. }
  10707. }
  10708. if (strpos($pattern, '*') !== false) {
  10709. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  10710. } else {
  10711. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  10712. }
  10713. }
  10714. }
  10715. private function unlockPackage(Request $request, $name)
  10716. {
  10717. if (
  10718. $this->skippedLoad[$name] !== $name
  10719. && isset($this->skippedLoad[$this->skippedLoad[$name]])
  10720. ) {
  10721. $this->unlockPackage($request, $this->skippedLoad[$name]);
  10722. }
  10723. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name]);
  10724. foreach ($request->getLockedPackages() as $lockedPackage) {
  10725. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  10726. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  10727. $request->unlockPackage($lockedPackage);
  10728. $this->removeLoadedPackage($request, $lockedPackage, $index);
  10729. foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
  10730. if ($fixedOrLockedPackage !== $lockedPackage && isset($this->skippedLoad[$fixedOrLockedPackage->getName()])) {
  10731. foreach ($fixedOrLockedPackage->getRequires() as $requireLink) {
  10732. if ($requireLink->getTarget() === $lockedPackage->getName()) {
  10733. $this->markPackageNameForLoading($request, $lockedPackage->getName(), $requireLink->getConstraint());
  10734. }
  10735. }
  10736. }
  10737. }
  10738. }
  10739. }
  10740. }
  10741. }
  10742. private function removeLoadedPackage(Request $request, BasePackage $package, $index)
  10743. {
  10744. unset($this->packages[$index]);
  10745. if (isset($this->aliasMap[spl_object_hash($package)])) {
  10746. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  10747. $request->unlockPackage($aliasPackage);
  10748. unset($this->packages[$aliasIndex]);
  10749. }
  10750. unset($this->aliasMap[spl_object_hash($package)]);
  10751. }
  10752. }
  10753. }
  10754. <?php
  10755. namespace Composer\DependencyResolver;
  10756. use Composer\Package\CompletePackageInterface;
  10757. use Composer\Package\AliasPackage;
  10758. use Composer\Package\BasePackage;
  10759. use Composer\Package\PackageInterface;
  10760. use Composer\Package\RootPackageInterface;
  10761. use Composer\Repository\RepositorySet;
  10762. use Composer\Repository\LockArrayRepository;
  10763. use Composer\Semver\Constraint\Constraint;
  10764. use Composer\Semver\Constraint\ConstraintInterface;
  10765. use Composer\Package\Version\VersionParser;
  10766. class Problem
  10767. {
  10768. protected $reasonSeen;
  10769. protected $reasons = array();
  10770. protected $section = 0;
  10771. public function addRule(Rule $rule)
  10772. {
  10773. $this->addReason(spl_object_hash($rule), $rule);
  10774. }
  10775. public function getReasons()
  10776. {
  10777. return $this->reasons;
  10778. }
  10779. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10780. {
  10781. $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
  10782. if (count($reasons) === 1) {
  10783. reset($reasons);
  10784. $rule = current($reasons);
  10785. if (!in_array($rule->getReason(), array(Rule::RULE_ROOT_REQUIRE, Rule::RULE_FIXED), true)) {
  10786. throw new \LogicException("Single reason problems must contain a request rule.");
  10787. }
  10788. $reasonData = $rule->getReasonData();
  10789. $packageName = $reasonData['packageName'];
  10790. $constraint = $reasonData['constraint'];
  10791. if (isset($constraint)) {
  10792. $packages = $pool->whatProvides($packageName, $constraint);
  10793. } else {
  10794. $packages = array();
  10795. }
  10796. if (empty($packages)) {
  10797. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  10798. }
  10799. }
  10800. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  10801. }
  10802. public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10803. {
  10804. $messages = array();
  10805. $templates = array();
  10806. $parser = new VersionParser;
  10807. $deduplicatableRuleTypes = array(Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT);
  10808. foreach ($rules as $rule) {
  10809. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  10810. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && preg_match('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  10811. $template = preg_replace('{^\S+ \S+ }', '%s%s ', $message);
  10812. $messages[] = $template;
  10813. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  10814. } elseif ($message !== '') {
  10815. $messages[] = $message;
  10816. }
  10817. }
  10818. $result = array();
  10819. foreach (array_unique($messages) as $message) {
  10820. if (isset($templates[$message])) {
  10821. foreach ($templates[$message] as $package => $versions) {
  10822. uksort($versions, 'version_compare');
  10823. if (!$isVerbose) {
  10824. $versions = self::condenseVersionList($versions, 1);
  10825. }
  10826. if (count($versions) > 1) {
  10827. $message = preg_replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  10828. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  10829. } else {
  10830. $result[] = sprintf($message, $package, ' '.reset($versions));
  10831. }
  10832. }
  10833. } else {
  10834. $result[] = $message;
  10835. }
  10836. }
  10837. return "\n$indent- ".implode("\n$indent- ", $result);
  10838. }
  10839. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  10840. {
  10841. foreach ($this->reasons as $sectionRules) {
  10842. foreach ($sectionRules as $rule) {
  10843. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  10844. return true;
  10845. }
  10846. }
  10847. }
  10848. return false;
  10849. }
  10850. protected function addReason($id, Rule $reason)
  10851. {
  10852. if (!isset($this->reasonSeen[$id])) {
  10853. $this->reasonSeen[$id] = true;
  10854. $this->reasons[$this->section][] = $reason;
  10855. }
  10856. }
  10857. public function nextSection()
  10858. {
  10859. $this->section++;
  10860. }
  10861. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, ConstraintInterface $constraint = null)
  10862. {
  10863. if ($packageName === 'php' || $packageName === 'php-64bit' || $packageName === 'hhvm') {
  10864. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion());
  10865. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  10866. if (defined('HHVM_VERSION') || ($packageName === 'hhvm' && count($pool->whatProvides($packageName)) > 0)) {
  10867. return array($msg, 'your HHVM version does not satisfy that requirement.');
  10868. }
  10869. if ($packageName === 'hhvm') {
  10870. return array($msg, 'HHVM was not detected on this machine, make sure it is in your PATH.');
  10871. }
  10872. return array($msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.');
  10873. }
  10874. if (0 === stripos($packageName, 'ext-')) {
  10875. if (false !== strpos($packageName, ' ')) {
  10876. return array('- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.');
  10877. }
  10878. $ext = substr($packageName, 4);
  10879. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion($ext) ?: '0');
  10880. $error = extension_loaded($ext) ? 'it has the wrong version ('.$version.') installed' : 'it is missing from your system';
  10881. return array("- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ', $error.'. Install or enable PHP\'s '.$ext.' extension.');
  10882. }
  10883. if (0 === stripos($packageName, 'lib-')) {
  10884. if (strtolower($packageName) === 'lib-icu') {
  10885. $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.';
  10886. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error);
  10887. }
  10888. 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.');
  10889. }
  10890. $lockedPackage = null;
  10891. foreach ($request->getLockedPackages() as $package) {
  10892. if ($package->getName() === $packageName) {
  10893. $lockedPackage = $package;
  10894. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10895. 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.');
  10896. }
  10897. break;
  10898. }
  10899. }
  10900. if ($packages = $repositorySet->findPackages($packageName, $constraint)) {
  10901. $rootReqs = $repositorySet->getRootRequires();
  10902. if (isset($rootReqs[$packageName])) {
  10903. $filtered = array_filter($packages, function ($p) use ($rootReqs, $packageName) {
  10904. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  10905. });
  10906. if (0 === count($filtered)) {
  10907. 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().').');
  10908. }
  10909. }
  10910. if ($lockedPackage) {
  10911. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  10912. $filtered = array_filter($packages, function ($p) use ($fixedConstraint) {
  10913. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  10914. });
  10915. if (0 === count($filtered)) {
  10916. 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.');
  10917. }
  10918. }
  10919. $nonLockedPackages = array_filter($packages, function ($p) {
  10920. return !$p->getRepository() instanceof LockArrayRepository;
  10921. });
  10922. if (!$nonLockedPackages) {
  10923. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.');
  10924. }
  10925. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but these were not loaded, likely because '.(self::hasMultipleNames($packages) ? 'they conflict' : 'it conflicts').' with another require.');
  10926. }
  10927. if ($packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10928. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10929. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $packages, $allReposPackages, 'minimum-stability', $constraint);
  10930. }
  10931. 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.');
  10932. }
  10933. if ($packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10934. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10935. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $packages, $allReposPackages, 'constraint', $constraint);
  10936. }
  10937. $suffix = '';
  10938. if ($constraint instanceof Constraint && $constraint->getVersion() === 'dev-master') {
  10939. foreach ($packages as $candidate) {
  10940. if (in_array($candidate->getVersion(), array('dev-default', 'dev-main'), true)) {
  10941. $suffix = ' Perhaps dev-master was renamed to '.$candidate->getPrettyVersion().'?';
  10942. break;
  10943. }
  10944. }
  10945. }
  10946. $allReposPackages = $packages;
  10947. $topPackage = reset($allReposPackages);
  10948. if ($topPackage instanceof RootPackageInterface) {
  10949. $suffix = ' See https://getcomposer.org/dep-on-root for details and assistance.';
  10950. }
  10951. 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.' . $suffix);
  10952. }
  10953. if (!preg_match('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  10954. $illegalChars = preg_replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  10955. 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.');
  10956. }
  10957. if ($providers = $repositorySet->getProviders($packageName)) {
  10958. $maxProviders = 20;
  10959. $providersStr = implode(array_map(function ($p) {
  10960. $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
  10961. return " - ${p['name']}".$description."\n";
  10962. }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers));
  10963. if (count($providers) > $maxProviders + 1) {
  10964. $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n";
  10965. }
  10966. 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.");
  10967. }
  10968. return array("- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name.");
  10969. }
  10970. public static function getPackageList(array $packages, $isVerbose)
  10971. {
  10972. $prepared = array();
  10973. $hasDefaultBranch = array();
  10974. foreach ($packages as $package) {
  10975. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  10976. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  10977. if ($package->isDefaultBranch()) {
  10978. $hasDefaultBranch[$package->getName()] = true;
  10979. }
  10980. }
  10981. foreach ($prepared as $name => $package) {
  10982. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  10983. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  10984. }
  10985. uksort($package['versions'], 'version_compare');
  10986. if (!$isVerbose) {
  10987. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  10988. }
  10989. $prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
  10990. }
  10991. return implode(', ', $prepared);
  10992. }
  10993. private static function getPlatformPackageVersion(Pool $pool, $packageName, $version)
  10994. {
  10995. $available = $pool->whatProvides($packageName);
  10996. if (count($available)) {
  10997. $firstAvailable = reset($available);
  10998. $version = $firstAvailable->getPrettyVersion();
  10999. $extra = $firstAvailable->getExtra();
  11000. if ($firstAvailable instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  11001. $version .= '; ' . str_replace('Package ', '', $firstAvailable->getDescription());
  11002. }
  11003. }
  11004. return $version;
  11005. }
  11006. private static function condenseVersionList(array $versions, $max, $maxDev = 16)
  11007. {
  11008. if (count($versions) <= $max) {
  11009. return $versions;
  11010. }
  11011. $filtered = array();
  11012. $byMajor = array();
  11013. foreach ($versions as $version => $pretty) {
  11014. if (0 === stripos($version, 'dev-')) {
  11015. $byMajor['dev'][] = $pretty;
  11016. } else {
  11017. $byMajor[preg_replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
  11018. }
  11019. }
  11020. foreach ($byMajor as $majorVersion => $versionsForMajor) {
  11021. $maxVersions = $majorVersion === 'dev' ? $maxDev : $max;
  11022. if (count($versionsForMajor) > $maxVersions) {
  11023. $filtered[] = $versionsForMajor[0];
  11024. $filtered[] = '...';
  11025. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  11026. } else {
  11027. $filtered = array_merge($filtered, $versionsForMajor);
  11028. }
  11029. }
  11030. return $filtered;
  11031. }
  11032. private static function hasMultipleNames(array $packages)
  11033. {
  11034. $name = null;
  11035. foreach ($packages as $package) {
  11036. if ($name === null || $name === $package->getName()) {
  11037. $name = $package->getName();
  11038. } else {
  11039. return true;
  11040. }
  11041. }
  11042. return false;
  11043. }
  11044. private static function computeCheckForLowerPrioRepo($isVerbose, $packageName, array $higherRepoPackages, array $allReposPackages, $reason, ConstraintInterface $constraint = null)
  11045. {
  11046. $nextRepoPackages = array();
  11047. $nextRepo = null;
  11048. foreach ($allReposPackages as $package) {
  11049. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  11050. $nextRepoPackages[] = $package;
  11051. $nextRepo = $package->getRepository();
  11052. } else {
  11053. break;
  11054. }
  11055. }
  11056. if ($higherRepoPackages) {
  11057. $topPackage = reset($higherRepoPackages);
  11058. if ($topPackage instanceof RootPackageInterface) {
  11059. return array(
  11060. "- Root composer.json requires $packageName".self::constraintToText($constraint).', it is ',
  11061. 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose).' from '.$nextRepo->getRepoName().' but '.$topPackage->getPrettyName().' is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance.',
  11062. );
  11063. }
  11064. }
  11065. if ($nextRepo instanceof LockArrayRepository) {
  11066. $singular = count($higherRepoPackages) === 1;
  11067. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ',
  11068. 'found '.self::getPackageList($nextRepoPackages, $isVerbose).' in the lock file and '.self::getPackageList($higherRepoPackages, $isVerbose).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' but ' . ($singular ? 'it does' : 'these do') . ' not match your '.$reason.' and ' . ($singular ? 'is' : 'are') . ' therefore not installable. Make sure you either fix the '.$reason.' or avoid updating this package to keep the one from the lock file.', );
  11069. }
  11070. 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.');
  11071. }
  11072. protected static function constraintToText(ConstraintInterface $constraint = null)
  11073. {
  11074. return $constraint ? ' '.$constraint->getPrettyString() : '';
  11075. }
  11076. }
  11077. <?php
  11078. namespace Composer\DependencyResolver;
  11079. use Composer\Package\BasePackage;
  11080. use Composer\Package\PackageInterface;
  11081. use Composer\Repository\LockArrayRepository;
  11082. use Composer\Semver\Constraint\ConstraintInterface;
  11083. use Composer\Semver\Constraint\MatchAllConstraint;
  11084. class Request
  11085. {
  11086. const UPDATE_ONLY_LISTED = 0;
  11087. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  11088. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  11089. protected $lockedRepository;
  11090. protected $requires = array();
  11091. protected $fixedPackages = array();
  11092. protected $lockedPackages = array();
  11093. protected $fixedLockedPackages = array();
  11094. protected $updateAllowList = array();
  11095. protected $updateAllowTransitiveDependencies = false;
  11096. public function __construct(LockArrayRepository $lockedRepository = null)
  11097. {
  11098. $this->lockedRepository = $lockedRepository;
  11099. }
  11100. public function requireName($packageName, ConstraintInterface $constraint = null)
  11101. {
  11102. $packageName = strtolower($packageName);
  11103. if ($constraint === null) {
  11104. $constraint = new MatchAllConstraint();
  11105. }
  11106. if (isset($this->requires[$packageName])) {
  11107. 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');
  11108. }
  11109. $this->requires[$packageName] = $constraint;
  11110. }
  11111. public function fixPackage(BasePackage $package)
  11112. {
  11113. $this->fixedPackages[spl_object_hash($package)] = $package;
  11114. }
  11115. public function lockPackage(BasePackage $package)
  11116. {
  11117. $this->lockedPackages[spl_object_hash($package)] = $package;
  11118. }
  11119. public function fixLockedPackage(BasePackage $package)
  11120. {
  11121. $this->fixedPackages[spl_object_hash($package)] = $package;
  11122. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  11123. }
  11124. public function unlockPackage(BasePackage $package)
  11125. {
  11126. unset($this->lockedPackages[spl_object_hash($package)]);
  11127. }
  11128. public function setUpdateAllowList($updateAllowList, $updateAllowTransitiveDependencies)
  11129. {
  11130. $this->updateAllowList = $updateAllowList;
  11131. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  11132. }
  11133. public function getUpdateAllowList()
  11134. {
  11135. return $this->updateAllowList;
  11136. }
  11137. public function getUpdateAllowTransitiveDependencies()
  11138. {
  11139. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  11140. }
  11141. public function getUpdateAllowTransitiveRootDependencies()
  11142. {
  11143. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  11144. }
  11145. public function getRequires()
  11146. {
  11147. return $this->requires;
  11148. }
  11149. public function getFixedPackages()
  11150. {
  11151. return $this->fixedPackages;
  11152. }
  11153. public function isFixedPackage(BasePackage $package)
  11154. {
  11155. return isset($this->fixedPackages[spl_object_hash($package)]);
  11156. }
  11157. public function getLockedPackages()
  11158. {
  11159. return $this->lockedPackages;
  11160. }
  11161. public function isLockedPackage(PackageInterface $package)
  11162. {
  11163. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  11164. }
  11165. public function getFixedOrLockedPackages()
  11166. {
  11167. return array_merge($this->fixedPackages, $this->lockedPackages);
  11168. }
  11169. public function getPresentMap($packageIds = false)
  11170. {
  11171. $presentMap = array();
  11172. if ($this->lockedRepository) {
  11173. foreach ($this->lockedRepository->getPackages() as $package) {
  11174. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  11175. }
  11176. }
  11177. foreach ($this->fixedPackages as $package) {
  11178. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  11179. }
  11180. return $presentMap;
  11181. }
  11182. public function getFixedPackagesMap()
  11183. {
  11184. $fixedPackagesMap = array();
  11185. foreach ($this->fixedPackages as $package) {
  11186. $fixedPackagesMap[$package->getId()] = $package;
  11187. }
  11188. return $fixedPackagesMap;
  11189. }
  11190. public function getLockedRepository()
  11191. {
  11192. return $this->lockedRepository;
  11193. }
  11194. }
  11195. <?php
  11196. namespace Composer\DependencyResolver;
  11197. use Composer\Package\AliasPackage;
  11198. use Composer\Package\BasePackage;
  11199. use Composer\Package\Link;
  11200. use Composer\Repository\PlatformRepository;
  11201. use Composer\Repository\RepositorySet;
  11202. use Composer\Package\Version\VersionParser;
  11203. use Composer\Semver\Constraint\Constraint;
  11204. use Composer\Semver\Constraint\ConstraintInterface;
  11205. abstract class Rule
  11206. {
  11207. const RULE_ROOT_REQUIRE = 2;
  11208. const RULE_FIXED = 3;
  11209. const RULE_PACKAGE_CONFLICT = 6;
  11210. const RULE_PACKAGE_REQUIRES = 7;
  11211. const RULE_PACKAGE_SAME_NAME = 10;
  11212. const RULE_LEARNED = 12;
  11213. const RULE_PACKAGE_ALIAS = 13;
  11214. const RULE_PACKAGE_INVERSE_ALIAS = 14;
  11215. const BITFIELD_TYPE = 0;
  11216. const BITFIELD_REASON = 8;
  11217. const BITFIELD_DISABLED = 16;
  11218. protected $bitfield;
  11219. protected $request;
  11220. protected $reasonData;
  11221. public function __construct($reason, $reasonData)
  11222. {
  11223. $this->reasonData = $reasonData;
  11224. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  11225. ($reason << self::BITFIELD_REASON) |
  11226. (255 << self::BITFIELD_TYPE);
  11227. }
  11228. abstract public function getLiterals();
  11229. abstract public function getHash();
  11230. abstract public function __toString();
  11231. abstract public function equals(Rule $rule);
  11232. public function getReason()
  11233. {
  11234. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  11235. }
  11236. public function getReasonData()
  11237. {
  11238. return $this->reasonData;
  11239. }
  11240. public function getRequiredPackage()
  11241. {
  11242. $reason = $this->getReason();
  11243. if ($reason === self::RULE_ROOT_REQUIRE) {
  11244. return $this->reasonData['packageName'];
  11245. }
  11246. if ($reason === self::RULE_FIXED) {
  11247. return $this->reasonData['package']->getName();
  11248. }
  11249. if ($reason === self::RULE_PACKAGE_REQUIRES) {
  11250. return $this->reasonData->getTarget();
  11251. }
  11252. return null;
  11253. }
  11254. public function setType($type)
  11255. {
  11256. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  11257. }
  11258. public function getType()
  11259. {
  11260. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  11261. }
  11262. public function disable()
  11263. {
  11264. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  11265. }
  11266. public function enable()
  11267. {
  11268. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  11269. }
  11270. public function isDisabled()
  11271. {
  11272. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  11273. }
  11274. public function isEnabled()
  11275. {
  11276. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  11277. }
  11278. abstract public function isAssertion();
  11279. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  11280. {
  11281. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  11282. if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
  11283. return false;
  11284. }
  11285. if ($request->getLockedRepository()) {
  11286. foreach ($request->getLockedRepository()->getPackages() as $package) {
  11287. if ($package->getName() === $this->reasonData->getTarget()) {
  11288. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  11289. return true;
  11290. }
  11291. if (!$this->reasonData->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  11292. return true;
  11293. }
  11294. if (!$request->isLockedPackage($package)) {
  11295. return true;
  11296. }
  11297. break;
  11298. }
  11299. }
  11300. }
  11301. }
  11302. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  11303. if (PlatformRepository::isPlatformPackage($this->reasonData['packageName'])) {
  11304. return false;
  11305. }
  11306. if ($request->getLockedRepository()) {
  11307. foreach ($request->getLockedRepository()->getPackages() as $package) {
  11308. if ($package->getName() === $this->reasonData['packageName']) {
  11309. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  11310. return true;
  11311. }
  11312. if (!$this->reasonData['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  11313. return true;
  11314. }
  11315. break;
  11316. }
  11317. }
  11318. }
  11319. }
  11320. return false;
  11321. }
  11322. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  11323. {
  11324. $literals = $this->getLiterals();
  11325. switch ($this->getReason()) {
  11326. case self::RULE_ROOT_REQUIRE:
  11327. $packageName = $this->reasonData['packageName'];
  11328. $constraint = $this->reasonData['constraint'];
  11329. $packages = $pool->whatProvides($packageName, $constraint);
  11330. if (!$packages) {
  11331. return 'No package found to satisfy root composer.json require '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '');
  11332. }
  11333. $packagesNonAlias = array_values(array_filter($packages, function ($p) {
  11334. return !($p instanceof AliasPackage);
  11335. }));
  11336. if (count($packagesNonAlias) === 1) {
  11337. $package = $packagesNonAlias[0];
  11338. if ($request->isLockedPackage($package)) {
  11339. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  11340. }
  11341. }
  11342. return 'Root composer.json requires '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '').' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose).'.';
  11343. case self::RULE_FIXED:
  11344. $package = $this->deduplicateDefaultBranchAlias($this->reasonData['package']);
  11345. if ($request->isLockedPackage($package)) {
  11346. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  11347. }
  11348. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  11349. case self::RULE_PACKAGE_CONFLICT:
  11350. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  11351. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  11352. $conflictTarget = $package1->getPrettyString();
  11353. if ($reasonData = $this->getReasonData()) {
  11354. if ($reasonData->getSource() === $package1->getName()) {
  11355. list($package2, $package1) = array($package1, $package2);
  11356. }
  11357. if ($reasonData->getTarget() !== $package1->getName()) {
  11358. $provideType = null;
  11359. $provided = null;
  11360. foreach ($package1->getProvides() as $provide) {
  11361. if ($provide->getTarget() === $reasonData->getTarget()) {
  11362. $provideType = 'provides';
  11363. $provided = $provide->getPrettyConstraint();
  11364. break;
  11365. }
  11366. }
  11367. foreach ($package1->getReplaces() as $replace) {
  11368. if ($replace->getTarget() === $reasonData->getTarget()) {
  11369. $provideType = 'replaces';
  11370. $provided = $replace->getPrettyConstraint();
  11371. break;
  11372. }
  11373. }
  11374. if (null !== $provideType) {
  11375. $conflictTarget = $reasonData->getTarget().' '.$reasonData->getPrettyConstraint().' ('.$package1->getPrettyString().' '.$provideType.' '.$reasonData->getTarget().' '.$provided.')';
  11376. }
  11377. }
  11378. }
  11379. return $package2->getPrettyString().' conflicts with '.$conflictTarget.'.';
  11380. case self::RULE_PACKAGE_REQUIRES:
  11381. $sourceLiteral = array_shift($literals);
  11382. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  11383. $reasonData = $this->reasonData;
  11384. $requires = array();
  11385. foreach ($literals as $literal) {
  11386. $requires[] = $pool->literalToPackage($literal);
  11387. }
  11388. $text = $reasonData->getPrettyString($sourcePackage);
  11389. if ($requires) {
  11390. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose) . '.';
  11391. } else {
  11392. $targetName = $reasonData->getTarget();
  11393. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $this->reasonData->getConstraint());
  11394. return $text . ' -> ' . $reason[1];
  11395. }
  11396. return $text;
  11397. case self::RULE_PACKAGE_SAME_NAME:
  11398. $packageNames = array();
  11399. foreach ($literals as $literal) {
  11400. $package = $pool->literalToPackage($literal);
  11401. $packageNames[$package->getName()] = true;
  11402. }
  11403. $replacedName = $this->reasonData;
  11404. if (count($packageNames) > 1) {
  11405. $reason = null;
  11406. if (!isset($packageNames[$replacedName])) {
  11407. $reason = 'They '.(count($literals) == 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  11408. } else {
  11409. $replacerNames = $packageNames;
  11410. unset($replacerNames[$replacedName]);
  11411. $replacerNames = array_keys($replacerNames);
  11412. if (count($replacerNames) == 1) {
  11413. $reason = $replacerNames[0] . ' replaces ';
  11414. } else {
  11415. $reason = '['.implode(', ', $replacerNames).'] replace ';
  11416. }
  11417. $reason .= $replacedName.' and thus cannot coexist with it.';
  11418. }
  11419. $installedPackages = array();
  11420. $removablePackages = array();
  11421. foreach ($literals as $literal) {
  11422. if (isset($installedMap[abs($literal)])) {
  11423. $installedPackages[] = $pool->literalToPackage($literal);
  11424. } else {
  11425. $removablePackages[] = $pool->literalToPackage($literal);
  11426. }
  11427. }
  11428. if ($installedPackages && $removablePackages) {
  11429. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose).'. '.$reason;
  11430. }
  11431. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose).'. '.$reason;
  11432. }
  11433. return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose) . '.';
  11434. case self::RULE_LEARNED:
  11435. $learnedString = ' (conflict analysis result)';
  11436. if (count($literals) === 1) {
  11437. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  11438. } else {
  11439. $groups = array();
  11440. foreach ($literals as $literal) {
  11441. $package = $pool->literalToPackage($literal);
  11442. if (isset($installedMap[$package->id])) {
  11443. $group = $literal > 0 ? 'keep' : 'remove';
  11444. } else {
  11445. $group = $literal > 0 ? 'install' : 'don\'t install';
  11446. }
  11447. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  11448. }
  11449. $ruleTexts = array();
  11450. foreach ($groups as $group => $packages) {
  11451. $ruleTexts[] = $group . (count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  11452. }
  11453. $ruleText = implode(' | ', $ruleTexts);
  11454. }
  11455. return 'Conclusion: '.$ruleText.$learnedString;
  11456. case self::RULE_PACKAGE_ALIAS:
  11457. $aliasPackage = $pool->literalToPackage($literals[0]);
  11458. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  11459. return '';
  11460. }
  11461. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  11462. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  11463. case self::RULE_PACKAGE_INVERSE_ALIAS:
  11464. $aliasPackage = $pool->literalToPackage($literals[1]);
  11465. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  11466. return '';
  11467. }
  11468. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  11469. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and must be installed with it.';
  11470. default:
  11471. $ruleText = '';
  11472. foreach ($literals as $i => $literal) {
  11473. if ($i != 0) {
  11474. $ruleText .= '|';
  11475. }
  11476. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  11477. }
  11478. return '('.$ruleText.')';
  11479. }
  11480. }
  11481. protected function formatPackagesUnique(Pool $pool, array $packages, $isVerbose)
  11482. {
  11483. foreach ($packages as $index => $package) {
  11484. if (!\is_object($package)) {
  11485. $packages[$index] = $pool->literalToPackage($package);
  11486. }
  11487. }
  11488. return Problem::getPackageList($packages, $isVerbose);
  11489. }
  11490. private function deduplicateDefaultBranchAlias(BasePackage $package)
  11491. {
  11492. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  11493. $package = $package->getAliasOf();
  11494. }
  11495. return $package;
  11496. }
  11497. }
  11498. <?php
  11499. namespace Composer\DependencyResolver;
  11500. class Rule2Literals extends Rule
  11501. {
  11502. protected $literal1;
  11503. protected $literal2;
  11504. public function __construct($literal1, $literal2, $reason, $reasonData)
  11505. {
  11506. parent::__construct($reason, $reasonData);
  11507. if ($literal1 < $literal2) {
  11508. $this->literal1 = $literal1;
  11509. $this->literal2 = $literal2;
  11510. } else {
  11511. $this->literal1 = $literal2;
  11512. $this->literal2 = $literal1;
  11513. }
  11514. }
  11515. public function getLiterals()
  11516. {
  11517. return array($this->literal1, $this->literal2);
  11518. }
  11519. public function getHash()
  11520. {
  11521. return $this->literal1.','.$this->literal2;
  11522. }
  11523. public function equals(Rule $rule)
  11524. {
  11525. if ($rule instanceof self) {
  11526. if ($this->literal1 !== $rule->literal1) {
  11527. return false;
  11528. }
  11529. if ($this->literal2 !== $rule->literal2) {
  11530. return false;
  11531. }
  11532. return true;
  11533. }
  11534. $literals = $rule->getLiterals();
  11535. if (2 != \count($literals)) {
  11536. return false;
  11537. }
  11538. if ($this->literal1 !== $literals[0]) {
  11539. return false;
  11540. }
  11541. if ($this->literal2 !== $literals[1]) {
  11542. return false;
  11543. }
  11544. return true;
  11545. }
  11546. public function isAssertion()
  11547. {
  11548. return false;
  11549. }
  11550. public function __toString()
  11551. {
  11552. $result = $this->isDisabled() ? 'disabled(' : '(';
  11553. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  11554. return $result;
  11555. }
  11556. }
  11557. <?php
  11558. namespace Composer\DependencyResolver;
  11559. use Composer\Repository\RepositorySet;
  11560. class RuleSet implements \IteratorAggregate, \Countable
  11561. {
  11562. const TYPE_PACKAGE = 0;
  11563. const TYPE_REQUEST = 1;
  11564. const TYPE_LEARNED = 4;
  11565. public $ruleById = array();
  11566. protected static $types = array(
  11567. self::TYPE_PACKAGE => 'PACKAGE',
  11568. self::TYPE_REQUEST => 'REQUEST',
  11569. self::TYPE_LEARNED => 'LEARNED',
  11570. );
  11571. protected $rules;
  11572. protected $nextRuleId = 0;
  11573. protected $rulesByHash = array();
  11574. public function __construct()
  11575. {
  11576. foreach ($this->getTypes() as $type) {
  11577. $this->rules[$type] = array();
  11578. }
  11579. }
  11580. public function add(Rule $rule, $type)
  11581. {
  11582. if (!isset(self::$types[$type])) {
  11583. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  11584. }
  11585. $hash = $rule->getHash();
  11586. if (isset($this->rulesByHash[$hash])) {
  11587. $potentialDuplicates = $this->rulesByHash[$hash];
  11588. if (\is_array($potentialDuplicates)) {
  11589. foreach ($potentialDuplicates as $potentialDuplicate) {
  11590. if ($rule->equals($potentialDuplicate)) {
  11591. return;
  11592. }
  11593. }
  11594. } else {
  11595. if ($rule->equals($potentialDuplicates)) {
  11596. return;
  11597. }
  11598. }
  11599. }
  11600. if (!isset($this->rules[$type])) {
  11601. $this->rules[$type] = array();
  11602. }
  11603. $this->rules[$type][] = $rule;
  11604. $this->ruleById[$this->nextRuleId] = $rule;
  11605. $rule->setType($type);
  11606. $this->nextRuleId++;
  11607. if (!isset($this->rulesByHash[$hash])) {
  11608. $this->rulesByHash[$hash] = $rule;
  11609. } elseif (\is_array($this->rulesByHash[$hash])) {
  11610. $this->rulesByHash[$hash][] = $rule;
  11611. } else {
  11612. $originalRule = $this->rulesByHash[$hash];
  11613. $this->rulesByHash[$hash] = array($originalRule, $rule);
  11614. }
  11615. }
  11616. #[\ReturnTypeWillChange]
  11617. public function count()
  11618. {
  11619. return $this->nextRuleId;
  11620. }
  11621. public function ruleById($id)
  11622. {
  11623. return $this->ruleById[$id];
  11624. }
  11625. public function getRules()
  11626. {
  11627. return $this->rules;
  11628. }
  11629. #[\ReturnTypeWillChange]
  11630. public function getIterator()
  11631. {
  11632. return new RuleSetIterator($this->getRules());
  11633. }
  11634. public function getIteratorFor($types)
  11635. {
  11636. if (!\is_array($types)) {
  11637. $types = array($types);
  11638. }
  11639. $allRules = $this->getRules();
  11640. $rules = array();
  11641. foreach ($types as $type) {
  11642. $rules[$type] = $allRules[$type];
  11643. }
  11644. return new RuleSetIterator($rules);
  11645. }
  11646. public function getIteratorWithout($types)
  11647. {
  11648. if (!\is_array($types)) {
  11649. $types = array($types);
  11650. }
  11651. $rules = $this->getRules();
  11652. foreach ($types as $type) {
  11653. unset($rules[$type]);
  11654. }
  11655. return new RuleSetIterator($rules);
  11656. }
  11657. public function getTypes()
  11658. {
  11659. $types = self::$types;
  11660. return array_keys($types);
  11661. }
  11662. public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false)
  11663. {
  11664. $string = "\n";
  11665. foreach ($this->rules as $type => $rules) {
  11666. $string .= str_pad(self::$types[$type], 8, ' ') . ": ";
  11667. foreach ($rules as $rule) {
  11668. $string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  11669. }
  11670. $string .= "\n\n";
  11671. }
  11672. return $string;
  11673. }
  11674. public function __toString()
  11675. {
  11676. return $this->getPrettyString();
  11677. }
  11678. }
  11679. <?php
  11680. namespace Composer\DependencyResolver;
  11681. use Composer\Package\BasePackage;
  11682. use Composer\Package\AliasPackage;
  11683. use Composer\Repository\PlatformRepository;
  11684. class RuleSetGenerator
  11685. {
  11686. protected $policy;
  11687. protected $pool;
  11688. protected $rules;
  11689. protected $addedMap = array();
  11690. protected $addedPackagesByNames = array();
  11691. public function __construct(PolicyInterface $policy, Pool $pool)
  11692. {
  11693. $this->policy = $policy;
  11694. $this->pool = $pool;
  11695. $this->rules = new RuleSet;
  11696. }
  11697. protected function createRequireRule(BasePackage $package, array $providers, $reason, $reasonData = null)
  11698. {
  11699. $literals = array(-$package->id);
  11700. foreach ($providers as $provider) {
  11701. if ($provider === $package) {
  11702. return null;
  11703. }
  11704. $literals[] = $provider->id;
  11705. }
  11706. return new GenericRule($literals, $reason, $reasonData);
  11707. }
  11708. protected function createInstallOneOfRule(array $packages, $reason, $reasonData)
  11709. {
  11710. $literals = array();
  11711. foreach ($packages as $package) {
  11712. $literals[] = $package->id;
  11713. }
  11714. return new GenericRule($literals, $reason, $reasonData);
  11715. }
  11716. protected function createRule2Literals(BasePackage $issuer, BasePackage $provider, $reason, $reasonData = null)
  11717. {
  11718. if ($issuer === $provider) {
  11719. return null;
  11720. }
  11721. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  11722. }
  11723. protected function createMultiConflictRule(array $packages, $reason, $reasonData)
  11724. {
  11725. $literals = array();
  11726. foreach ($packages as $package) {
  11727. $literals[] = -$package->id;
  11728. }
  11729. if (\count($literals) == 2) {
  11730. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  11731. }
  11732. return new MultiConflictRule($literals, $reason, $reasonData);
  11733. }
  11734. private function addRule($type, Rule $newRule = null)
  11735. {
  11736. if (!$newRule) {
  11737. return;
  11738. }
  11739. $this->rules->add($newRule, $type);
  11740. }
  11741. protected function addRulesForPackage(BasePackage $package, $ignorePlatformReqs)
  11742. {
  11743. $workQueue = new \SplQueue;
  11744. $workQueue->enqueue($package);
  11745. while (!$workQueue->isEmpty()) {
  11746. $package = $workQueue->dequeue();
  11747. if (isset($this->addedMap[$package->id])) {
  11748. continue;
  11749. }
  11750. $this->addedMap[$package->id] = $package;
  11751. if (!$package instanceof AliasPackage) {
  11752. foreach ($package->getNames(false) as $name) {
  11753. $this->addedPackagesByNames[$name][] = $package;
  11754. }
  11755. } else {
  11756. $workQueue->enqueue($package->getAliasOf());
  11757. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($package->getAliasOf()), Rule::RULE_PACKAGE_ALIAS, $package));
  11758. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package->getAliasOf(), array($package), Rule::RULE_PACKAGE_INVERSE_ALIAS, $package->getAliasOf()));
  11759. if (!$package->hasSelfVersionRequires()) {
  11760. continue;
  11761. }
  11762. }
  11763. foreach ($package->getRequires() as $link) {
  11764. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  11765. continue;
  11766. }
  11767. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  11768. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  11769. foreach ($possibleRequires as $require) {
  11770. $workQueue->enqueue($require);
  11771. }
  11772. }
  11773. }
  11774. }
  11775. protected function addConflictRules($ignorePlatformReqs = false)
  11776. {
  11777. foreach ($this->addedMap as $package) {
  11778. foreach ($package->getConflicts() as $link) {
  11779. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  11780. continue;
  11781. }
  11782. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  11783. continue;
  11784. }
  11785. $conflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  11786. foreach ($conflicts as $conflict) {
  11787. if (!$conflict instanceof AliasPackage || $conflict->getName() === $link->getTarget()) {
  11788. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  11789. }
  11790. }
  11791. }
  11792. }
  11793. foreach ($this->addedPackagesByNames as $name => $packages) {
  11794. if (\count($packages) > 1) {
  11795. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  11796. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  11797. }
  11798. }
  11799. }
  11800. protected function addRulesForRequest(Request $request, $ignorePlatformReqs)
  11801. {
  11802. foreach ($request->getFixedPackages() as $package) {
  11803. if ($package->id == -1) {
  11804. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  11805. continue;
  11806. }
  11807. throw new \LogicException("Fixed package ".$package->getPrettyString()." was not added to solver pool.");
  11808. }
  11809. $this->addRulesForPackage($package, $ignorePlatformReqs);
  11810. $rule = $this->createInstallOneOfRule(array($package), Rule::RULE_FIXED, array(
  11811. 'package' => $package,
  11812. ));
  11813. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  11814. }
  11815. foreach ($request->getRequires() as $packageName => $constraint) {
  11816. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  11817. continue;
  11818. }
  11819. $packages = $this->pool->whatProvides($packageName, $constraint);
  11820. if ($packages) {
  11821. foreach ($packages as $package) {
  11822. $this->addRulesForPackage($package, $ignorePlatformReqs);
  11823. }
  11824. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, array(
  11825. 'packageName' => $packageName,
  11826. 'constraint' => $constraint,
  11827. ));
  11828. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  11829. }
  11830. }
  11831. }
  11832. protected function addRulesForRootAliases($ignorePlatformReqs)
  11833. {
  11834. foreach ($this->pool->getPackages() as $package) {
  11835. if (!isset($this->addedMap[$package->id]) &&
  11836. $package instanceof AliasPackage &&
  11837. ($package->isRootPackageAlias() || isset($this->addedMap[$package->getAliasOf()->id]))
  11838. ) {
  11839. $this->addRulesForPackage($package, $ignorePlatformReqs);
  11840. }
  11841. }
  11842. }
  11843. public function getRulesFor(Request $request, $ignorePlatformReqs = false)
  11844. {
  11845. $this->addRulesForRequest($request, $ignorePlatformReqs);
  11846. $this->addRulesForRootAliases($ignorePlatformReqs);
  11847. $this->addConflictRules($ignorePlatformReqs);
  11848. $this->addedMap = $this->addedPackagesByNames = array();
  11849. $rules = $this->rules;
  11850. $this->rules = new RuleSet;
  11851. return $rules;
  11852. }
  11853. }
  11854. <?php
  11855. namespace Composer\DependencyResolver;
  11856. class RuleSetIterator implements \Iterator
  11857. {
  11858. protected $rules;
  11859. protected $types;
  11860. protected $currentOffset;
  11861. protected $currentType;
  11862. protected $currentTypeOffset;
  11863. public function __construct(array $rules)
  11864. {
  11865. $this->rules = $rules;
  11866. $this->types = array_keys($rules);
  11867. sort($this->types);
  11868. $this->rewind();
  11869. }
  11870. #[\ReturnTypeWillChange]
  11871. public function current()
  11872. {
  11873. return $this->rules[$this->currentType][$this->currentOffset];
  11874. }
  11875. #[\ReturnTypeWillChange]
  11876. public function key()
  11877. {
  11878. return $this->currentType;
  11879. }
  11880. #[\ReturnTypeWillChange]
  11881. public function next()
  11882. {
  11883. $this->currentOffset++;
  11884. if (!isset($this->rules[$this->currentType])) {
  11885. return;
  11886. }
  11887. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  11888. $this->currentOffset = 0;
  11889. do {
  11890. $this->currentTypeOffset++;
  11891. if (!isset($this->types[$this->currentTypeOffset])) {
  11892. $this->currentType = -1;
  11893. break;
  11894. }
  11895. $this->currentType = $this->types[$this->currentTypeOffset];
  11896. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  11897. }
  11898. }
  11899. #[\ReturnTypeWillChange]
  11900. public function rewind()
  11901. {
  11902. $this->currentOffset = 0;
  11903. $this->currentTypeOffset = -1;
  11904. $this->currentType = -1;
  11905. do {
  11906. $this->currentTypeOffset++;
  11907. if (!isset($this->types[$this->currentTypeOffset])) {
  11908. $this->currentType = -1;
  11909. break;
  11910. }
  11911. $this->currentType = $this->types[$this->currentTypeOffset];
  11912. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  11913. }
  11914. #[\ReturnTypeWillChange]
  11915. public function valid()
  11916. {
  11917. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  11918. }
  11919. }
  11920. <?php
  11921. namespace Composer\DependencyResolver;
  11922. class RuleWatchChain extends \SplDoublyLinkedList
  11923. {
  11924. public function seek($offset)
  11925. {
  11926. $this->rewind();
  11927. for ($i = 0; $i < $offset; $i++, $this->next());
  11928. }
  11929. public function remove()
  11930. {
  11931. $offset = $this->key();
  11932. $this->offsetUnset($offset);
  11933. $this->seek($offset);
  11934. }
  11935. }
  11936. <?php
  11937. namespace Composer\DependencyResolver;
  11938. class RuleWatchGraph
  11939. {
  11940. protected $watchChains = array();
  11941. public function insert(RuleWatchNode $node)
  11942. {
  11943. if ($node->getRule()->isAssertion()) {
  11944. return;
  11945. }
  11946. if (!$node->getRule() instanceof MultiConflictRule) {
  11947. foreach (array($node->watch1, $node->watch2) as $literal) {
  11948. if (!isset($this->watchChains[$literal])) {
  11949. $this->watchChains[$literal] = new RuleWatchChain;
  11950. }
  11951. $this->watchChains[$literal]->unshift($node);
  11952. }
  11953. } else {
  11954. foreach ($node->getRule()->getLiterals() as $literal) {
  11955. if (!isset($this->watchChains[$literal])) {
  11956. $this->watchChains[$literal] = new RuleWatchChain;
  11957. }
  11958. $this->watchChains[$literal]->unshift($node);
  11959. }
  11960. }
  11961. }
  11962. public function propagateLiteral($decidedLiteral, $level, Decisions $decisions)
  11963. {
  11964. $literal = -$decidedLiteral;
  11965. if (!isset($this->watchChains[$literal])) {
  11966. return null;
  11967. }
  11968. $chain = $this->watchChains[$literal];
  11969. $chain->rewind();
  11970. while ($chain->valid()) {
  11971. $node = $chain->current();
  11972. if (!$node->getRule() instanceof MultiConflictRule) {
  11973. $otherWatch = $node->getOtherWatch($literal);
  11974. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  11975. $ruleLiterals = $node->getRule()->getLiterals();
  11976. $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
  11977. return $literal !== $ruleLiteral &&
  11978. $otherWatch !== $ruleLiteral &&
  11979. !$decisions->conflict($ruleLiteral);
  11980. });
  11981. if ($alternativeLiterals) {
  11982. reset($alternativeLiterals);
  11983. $this->moveWatch($literal, current($alternativeLiterals), $node);
  11984. continue;
  11985. }
  11986. if ($decisions->conflict($otherWatch)) {
  11987. return $node->getRule();
  11988. }
  11989. $decisions->decide($otherWatch, $level, $node->getRule());
  11990. }
  11991. } else {
  11992. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  11993. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  11994. if ($decisions->conflict($otherLiteral)) {
  11995. return $node->getRule();
  11996. }
  11997. $decisions->decide($otherLiteral, $level, $node->getRule());
  11998. }
  11999. }
  12000. }
  12001. $chain->next();
  12002. }
  12003. return null;
  12004. }
  12005. protected function moveWatch($fromLiteral, $toLiteral, RuleWatchNode $node)
  12006. {
  12007. if (!isset($this->watchChains[$toLiteral])) {
  12008. $this->watchChains[$toLiteral] = new RuleWatchChain;
  12009. }
  12010. $node->moveWatch($fromLiteral, $toLiteral);
  12011. $this->watchChains[$fromLiteral]->remove();
  12012. $this->watchChains[$toLiteral]->unshift($node);
  12013. }
  12014. }
  12015. <?php
  12016. namespace Composer\DependencyResolver;
  12017. class RuleWatchNode
  12018. {
  12019. public $watch1;
  12020. public $watch2;
  12021. protected $rule;
  12022. public function __construct(Rule $rule)
  12023. {
  12024. $this->rule = $rule;
  12025. $literals = $rule->getLiterals();
  12026. $literalCount = \count($literals);
  12027. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  12028. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  12029. }
  12030. public function watch2OnHighest(Decisions $decisions)
  12031. {
  12032. $literals = $this->rule->getLiterals();
  12033. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  12034. return;
  12035. }
  12036. $watchLevel = 0;
  12037. foreach ($literals as $literal) {
  12038. $level = $decisions->decisionLevel($literal);
  12039. if ($level > $watchLevel) {
  12040. $this->watch2 = $literal;
  12041. $watchLevel = $level;
  12042. }
  12043. }
  12044. }
  12045. public function getRule()
  12046. {
  12047. return $this->rule;
  12048. }
  12049. public function getOtherWatch($literal)
  12050. {
  12051. if ($this->watch1 == $literal) {
  12052. return $this->watch2;
  12053. }
  12054. return $this->watch1;
  12055. }
  12056. public function moveWatch($from, $to)
  12057. {
  12058. if ($this->watch1 == $from) {
  12059. $this->watch1 = $to;
  12060. } else {
  12061. $this->watch2 = $to;
  12062. }
  12063. }
  12064. }
  12065. <?php
  12066. namespace Composer\DependencyResolver;
  12067. use Composer\IO\IOInterface;
  12068. use Composer\Package\BasePackage;
  12069. use Composer\Repository\PlatformRepository;
  12070. class Solver
  12071. {
  12072. const BRANCH_LITERALS = 0;
  12073. const BRANCH_LEVEL = 1;
  12074. protected $policy;
  12075. protected $pool;
  12076. protected $rules;
  12077. protected $watchGraph;
  12078. protected $decisions;
  12079. protected $fixedMap;
  12080. protected $propagateIndex;
  12081. protected $branches = array();
  12082. protected $problems = array();
  12083. protected $learnedPool = array();
  12084. protected $learnedWhy = array();
  12085. public $testFlagLearnedPositiveLiteral = false;
  12086. protected $io;
  12087. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  12088. {
  12089. $this->io = $io;
  12090. $this->policy = $policy;
  12091. $this->pool = $pool;
  12092. }
  12093. public function getRuleSetSize()
  12094. {
  12095. return \count($this->rules);
  12096. }
  12097. public function getPool()
  12098. {
  12099. return $this->pool;
  12100. }
  12101. private function makeAssertionRuleDecisions()
  12102. {
  12103. $decisionStart = \count($this->decisions) - 1;
  12104. $rulesCount = \count($this->rules);
  12105. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  12106. $rule = $this->rules->ruleById[$ruleIndex];
  12107. if (!$rule->isAssertion() || $rule->isDisabled()) {
  12108. continue;
  12109. }
  12110. $literals = $rule->getLiterals();
  12111. $literal = $literals[0];
  12112. if (!$this->decisions->decided($literal)) {
  12113. $this->decisions->decide($literal, 1, $rule);
  12114. continue;
  12115. }
  12116. if ($this->decisions->satisfy($literal)) {
  12117. continue;
  12118. }
  12119. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  12120. $rule->disable();
  12121. continue;
  12122. }
  12123. $conflict = $this->decisions->decisionRule($literal);
  12124. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  12125. $problem = new Problem();
  12126. $problem->addRule($rule);
  12127. $problem->addRule($conflict);
  12128. $rule->disable();
  12129. $this->problems[] = $problem;
  12130. continue;
  12131. }
  12132. $problem = new Problem();
  12133. $problem->addRule($rule);
  12134. $problem->addRule($conflict);
  12135. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  12136. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  12137. continue;
  12138. }
  12139. $assertRuleLiterals = $assertRule->getLiterals();
  12140. $assertRuleLiteral = $assertRuleLiterals[0];
  12141. if (abs($literal) !== abs($assertRuleLiteral)) {
  12142. continue;
  12143. }
  12144. $problem->addRule($assertRule);
  12145. $assertRule->disable();
  12146. }
  12147. $this->problems[] = $problem;
  12148. $this->decisions->resetToOffset($decisionStart);
  12149. $ruleIndex = -1;
  12150. }
  12151. }
  12152. protected function setupFixedMap(Request $request)
  12153. {
  12154. $this->fixedMap = array();
  12155. foreach ($request->getFixedPackages() as $package) {
  12156. $this->fixedMap[$package->id] = $package;
  12157. }
  12158. }
  12159. protected function checkForRootRequireProblems(Request $request, $ignorePlatformReqs)
  12160. {
  12161. foreach ($request->getRequires() as $packageName => $constraint) {
  12162. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  12163. continue;
  12164. }
  12165. if (!$this->pool->whatProvides($packageName, $constraint)) {
  12166. $problem = new Problem();
  12167. $problem->addRule(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, array('packageName' => $packageName, 'constraint' => $constraint)));
  12168. $this->problems[] = $problem;
  12169. }
  12170. }
  12171. }
  12172. public function solve(Request $request, $ignorePlatformReqs = false)
  12173. {
  12174. $this->setupFixedMap($request);
  12175. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  12176. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  12177. $this->rules = $ruleSetGenerator->getRulesFor($request, $ignorePlatformReqs);
  12178. unset($ruleSetGenerator);
  12179. $this->checkForRootRequireProblems($request, $ignorePlatformReqs);
  12180. $this->decisions = new Decisions($this->pool);
  12181. $this->watchGraph = new RuleWatchGraph;
  12182. foreach ($this->rules as $rule) {
  12183. $this->watchGraph->insert(new RuleWatchNode($rule));
  12184. }
  12185. $this->makeAssertionRuleDecisions();
  12186. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  12187. $before = microtime(true);
  12188. $this->runSat();
  12189. $this->io->writeError('', true, IOInterface::DEBUG);
  12190. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  12191. if ($this->problems) {
  12192. throw new SolverProblemsException($this->problems, $this->learnedPool);
  12193. }
  12194. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  12195. }
  12196. protected function propagate($level)
  12197. {
  12198. while ($this->decisions->validOffset($this->propagateIndex)) {
  12199. $decision = $this->decisions->atOffset($this->propagateIndex);
  12200. $conflict = $this->watchGraph->propagateLiteral(
  12201. $decision[Decisions::DECISION_LITERAL],
  12202. $level,
  12203. $this->decisions
  12204. );
  12205. $this->propagateIndex++;
  12206. if ($conflict) {
  12207. return $conflict;
  12208. }
  12209. }
  12210. return null;
  12211. }
  12212. private function revert($level)
  12213. {
  12214. while (!$this->decisions->isEmpty()) {
  12215. $literal = $this->decisions->lastLiteral();
  12216. if ($this->decisions->undecided($literal)) {
  12217. break;
  12218. }
  12219. $decisionLevel = $this->decisions->decisionLevel($literal);
  12220. if ($decisionLevel <= $level) {
  12221. break;
  12222. }
  12223. $this->decisions->revertLast();
  12224. $this->propagateIndex = \count($this->decisions);
  12225. }
  12226. while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  12227. array_pop($this->branches);
  12228. }
  12229. }
  12230. private function setPropagateLearn($level, $literal, Rule $rule)
  12231. {
  12232. $level++;
  12233. $this->decisions->decide($literal, $level, $rule);
  12234. while (true) {
  12235. $rule = $this->propagate($level);
  12236. if (!$rule) {
  12237. break;
  12238. }
  12239. if ($level == 1) {
  12240. return $this->analyzeUnsolvable($rule);
  12241. }
  12242. list($learnLiteral, $newLevel, $newRule, $why) = $this->analyze($level, $rule);
  12243. if ($newLevel <= 0 || $newLevel >= $level) {
  12244. throw new SolverBugException(
  12245. "Trying to revert to invalid level ".(int) $newLevel." from level ".(int) $level."."
  12246. );
  12247. }
  12248. $level = $newLevel;
  12249. $this->revert($level);
  12250. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  12251. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  12252. $ruleNode = new RuleWatchNode($newRule);
  12253. $ruleNode->watch2OnHighest($this->decisions);
  12254. $this->watchGraph->insert($ruleNode);
  12255. $this->decisions->decide($learnLiteral, $level, $newRule);
  12256. }
  12257. return $level;
  12258. }
  12259. private function selectAndInstall($level, array $decisionQueue, Rule $rule)
  12260. {
  12261. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  12262. $selectedLiteral = array_shift($literals);
  12263. if (\count($literals)) {
  12264. $this->branches[] = array($literals, $level);
  12265. }
  12266. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  12267. }
  12268. protected function analyze($level, Rule $rule)
  12269. {
  12270. $analyzedRule = $rule;
  12271. $ruleLevel = 1;
  12272. $num = 0;
  12273. $l1num = 0;
  12274. $seen = array();
  12275. $learnedLiterals = array(null);
  12276. $decisionId = \count($this->decisions);
  12277. $this->learnedPool[] = array();
  12278. while (true) {
  12279. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  12280. foreach ($rule->getLiterals() as $literal) {
  12281. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  12282. continue;
  12283. }
  12284. if ($this->decisions->satisfy($literal)) {
  12285. continue;
  12286. }
  12287. if (isset($seen[abs($literal)])) {
  12288. continue;
  12289. }
  12290. $seen[abs($literal)] = true;
  12291. $l = $this->decisions->decisionLevel($literal);
  12292. if (1 === $l) {
  12293. $l1num++;
  12294. } elseif ($level === $l) {
  12295. $num++;
  12296. } else {
  12297. $learnedLiterals[] = $literal;
  12298. if ($l > $ruleLevel) {
  12299. $ruleLevel = $l;
  12300. }
  12301. }
  12302. }
  12303. unset($literal);
  12304. $l1retry = true;
  12305. while ($l1retry) {
  12306. $l1retry = false;
  12307. if (!$num && !--$l1num) {
  12308. break 2;
  12309. }
  12310. while (true) {
  12311. if ($decisionId <= 0) {
  12312. throw new SolverBugException(
  12313. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  12314. );
  12315. }
  12316. $decisionId--;
  12317. $decision = $this->decisions->atOffset($decisionId);
  12318. $literal = $decision[Decisions::DECISION_LITERAL];
  12319. if (isset($seen[abs($literal)])) {
  12320. break;
  12321. }
  12322. }
  12323. unset($seen[abs($literal)]);
  12324. if ($num && 0 === --$num) {
  12325. if ($literal < 0) {
  12326. $this->testFlagLearnedPositiveLiteral = true;
  12327. }
  12328. $learnedLiterals[0] = -$literal;
  12329. if (!$l1num) {
  12330. break 2;
  12331. }
  12332. foreach ($learnedLiterals as $i => $learnedLiteral) {
  12333. if ($i !== 0) {
  12334. unset($seen[abs($learnedLiteral)]);
  12335. }
  12336. }
  12337. $l1num++;
  12338. $l1retry = true;
  12339. } else {
  12340. $decision = $this->decisions->atOffset($decisionId);
  12341. $rule = $decision[Decisions::DECISION_REASON];
  12342. if ($rule instanceof MultiConflictRule) {
  12343. foreach ($rule->getLiterals() as $literal) {
  12344. if (!isset($seen[abs($literal)]) && $this->decisions->satisfy(-$literal)) {
  12345. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  12346. $l = $this->decisions->decisionLevel($literal);
  12347. if (1 === $l) {
  12348. $l1num++;
  12349. } elseif ($level === $l) {
  12350. $num++;
  12351. } else {
  12352. $learnedLiterals[] = $literal;
  12353. if ($l > $ruleLevel) {
  12354. $ruleLevel = $l;
  12355. }
  12356. }
  12357. $seen[abs($literal)] = true;
  12358. break;
  12359. }
  12360. }
  12361. $l1retry = true;
  12362. }
  12363. }
  12364. }
  12365. $decision = $this->decisions->atOffset($decisionId);
  12366. $rule = $decision[Decisions::DECISION_REASON];
  12367. }
  12368. $why = \count($this->learnedPool) - 1;
  12369. if (!$learnedLiterals[0]) {
  12370. throw new SolverBugException(
  12371. "Did not find a learnable literal in analyzed rule $analyzedRule."
  12372. );
  12373. }
  12374. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  12375. return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
  12376. }
  12377. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen)
  12378. {
  12379. $why = spl_object_hash($conflictRule);
  12380. $ruleSeen[$why] = true;
  12381. if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
  12382. $learnedWhy = $this->learnedWhy[$why];
  12383. $problemRules = $this->learnedPool[$learnedWhy];
  12384. foreach ($problemRules as $problemRule) {
  12385. if (!isset($ruleSeen[spl_object_hash($problemRule)])) {
  12386. $this->analyzeUnsolvableRule($problem, $problemRule, $ruleSeen);
  12387. }
  12388. }
  12389. return;
  12390. }
  12391. if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {
  12392. return;
  12393. }
  12394. $problem->nextSection();
  12395. $problem->addRule($conflictRule);
  12396. }
  12397. private function analyzeUnsolvable(Rule $conflictRule)
  12398. {
  12399. $problem = new Problem();
  12400. $problem->addRule($conflictRule);
  12401. $ruleSeen = array();
  12402. $this->analyzeUnsolvableRule($problem, $conflictRule, $ruleSeen);
  12403. $this->problems[] = $problem;
  12404. $seen = array();
  12405. $literals = $conflictRule->getLiterals();
  12406. foreach ($literals as $literal) {
  12407. if ($this->decisions->satisfy($literal)) {
  12408. continue;
  12409. }
  12410. $seen[abs($literal)] = true;
  12411. }
  12412. foreach ($this->decisions as $decision) {
  12413. $literal = $decision[Decisions::DECISION_LITERAL];
  12414. if (!isset($seen[abs($literal)])) {
  12415. continue;
  12416. }
  12417. $why = $decision[Decisions::DECISION_REASON];
  12418. $problem->addRule($why);
  12419. $this->analyzeUnsolvableRule($problem, $why, $ruleSeen);
  12420. $literals = $why->getLiterals();
  12421. foreach ($literals as $literal) {
  12422. if ($this->decisions->satisfy($literal)) {
  12423. continue;
  12424. }
  12425. $seen[abs($literal)] = true;
  12426. }
  12427. }
  12428. return 0;
  12429. }
  12430. private function enableDisableLearnedRules()
  12431. {
  12432. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
  12433. $why = $this->learnedWhy[spl_object_hash($rule)];
  12434. $problemRules = $this->learnedPool[$why];
  12435. $foundDisabled = false;
  12436. foreach ($problemRules as $problemRule) {
  12437. if ($problemRule->isDisabled()) {
  12438. $foundDisabled = true;
  12439. break;
  12440. }
  12441. }
  12442. if ($foundDisabled && $rule->isEnabled()) {
  12443. $rule->disable();
  12444. } elseif (!$foundDisabled && $rule->isDisabled()) {
  12445. $rule->enable();
  12446. }
  12447. }
  12448. }
  12449. private function runSat()
  12450. {
  12451. $this->propagateIndex = 0;
  12452. $level = 1;
  12453. $systemLevel = $level + 1;
  12454. while (true) {
  12455. if (1 === $level) {
  12456. $conflictRule = $this->propagate($level);
  12457. if (null !== $conflictRule) {
  12458. if ($this->analyzeUnsolvable($conflictRule)) {
  12459. continue;
  12460. }
  12461. return;
  12462. }
  12463. }
  12464. if ($level < $systemLevel) {
  12465. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  12466. foreach ($iterator as $rule) {
  12467. if ($rule->isEnabled()) {
  12468. $decisionQueue = array();
  12469. $noneSatisfied = true;
  12470. foreach ($rule->getLiterals() as $literal) {
  12471. if ($this->decisions->satisfy($literal)) {
  12472. $noneSatisfied = false;
  12473. break;
  12474. }
  12475. if ($literal > 0 && $this->decisions->undecided($literal)) {
  12476. $decisionQueue[] = $literal;
  12477. }
  12478. }
  12479. if ($noneSatisfied && \count($decisionQueue)) {
  12480. $prunedQueue = array();
  12481. foreach ($decisionQueue as $literal) {
  12482. if (isset($this->fixedMap[abs($literal)])) {
  12483. $prunedQueue[] = $literal;
  12484. }
  12485. }
  12486. if (!empty($prunedQueue)) {
  12487. $decisionQueue = $prunedQueue;
  12488. }
  12489. }
  12490. if ($noneSatisfied && \count($decisionQueue)) {
  12491. $oLevel = $level;
  12492. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  12493. if (0 === $level) {
  12494. return;
  12495. }
  12496. if ($level <= $oLevel) {
  12497. break;
  12498. }
  12499. }
  12500. }
  12501. }
  12502. $systemLevel = $level + 1;
  12503. $iterator->next();
  12504. if ($iterator->valid()) {
  12505. continue;
  12506. }
  12507. }
  12508. if ($level < $systemLevel) {
  12509. $systemLevel = $level;
  12510. }
  12511. $rulesCount = \count($this->rules);
  12512. $pass = 1;
  12513. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  12514. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  12515. if ($i == $rulesCount) {
  12516. if (1 === $pass) {
  12517. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  12518. } else {
  12519. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  12520. }
  12521. $i = 0;
  12522. $pass++;
  12523. }
  12524. $rule = $this->rules->ruleById[$i];
  12525. $literals = $rule->getLiterals();
  12526. if ($rule->isDisabled()) {
  12527. continue;
  12528. }
  12529. $decisionQueue = array();
  12530. foreach ($literals as $literal) {
  12531. if ($literal <= 0) {
  12532. if (!$this->decisions->decidedInstall($literal)) {
  12533. continue 2;
  12534. }
  12535. } else {
  12536. if ($this->decisions->decidedInstall($literal)) {
  12537. continue 2;
  12538. }
  12539. if ($this->decisions->undecided($literal)) {
  12540. $decisionQueue[] = $literal;
  12541. }
  12542. }
  12543. }
  12544. if (\count($decisionQueue) < 2) {
  12545. continue;
  12546. }
  12547. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  12548. if (0 === $level) {
  12549. return;
  12550. }
  12551. $rulesCount = \count($this->rules);
  12552. $n = -1;
  12553. }
  12554. if ($level < $systemLevel) {
  12555. continue;
  12556. }
  12557. if (\count($this->branches)) {
  12558. $lastLiteral = null;
  12559. $lastLevel = null;
  12560. $lastBranchIndex = 0;
  12561. $lastBranchOffset = 0;
  12562. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  12563. list($literals, $l) = $this->branches[$i];
  12564. foreach ($literals as $offset => $literal) {
  12565. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  12566. $lastLiteral = $literal;
  12567. $lastBranchIndex = $i;
  12568. $lastBranchOffset = $offset;
  12569. $lastLevel = $l;
  12570. }
  12571. }
  12572. }
  12573. if ($lastLiteral) {
  12574. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  12575. $level = $lastLevel;
  12576. $this->revert($level);
  12577. $why = $this->decisions->lastReason();
  12578. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  12579. if ($level == 0) {
  12580. return;
  12581. }
  12582. continue;
  12583. }
  12584. }
  12585. break;
  12586. }
  12587. }
  12588. }
  12589. <?php
  12590. namespace Composer\DependencyResolver;
  12591. class SolverBugException extends \RuntimeException
  12592. {
  12593. public function __construct($message)
  12594. {
  12595. parent::__construct(
  12596. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  12597. "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"
  12598. );
  12599. }
  12600. }
  12601. <?php
  12602. namespace Composer\DependencyResolver;
  12603. use Composer\Util\IniHelper;
  12604. use Composer\Repository\RepositorySet;
  12605. class SolverProblemsException extends \RuntimeException
  12606. {
  12607. const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  12608. protected $problems;
  12609. protected $learnedPool;
  12610. public function __construct(array $problems, array $learnedPool)
  12611. {
  12612. $this->problems = $problems;
  12613. $this->learnedPool = $learnedPool;
  12614. parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', self::ERROR_DEPENDENCY_RESOLUTION_FAILED);
  12615. }
  12616. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
  12617. {
  12618. $installedMap = $request->getPresentMap(true);
  12619. $hasExtensionProblems = false;
  12620. $isCausedByLock = false;
  12621. $problems = array();
  12622. foreach ($this->problems as $problem) {
  12623. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  12624. if (!$hasExtensionProblems && $this->hasExtensionProblems($problem->getReasons())) {
  12625. $hasExtensionProblems = true;
  12626. }
  12627. $isCausedByLock = $isCausedByLock || $problem->isCausedByLock($repositorySet, $request, $pool);
  12628. }
  12629. $i = 1;
  12630. $text = "\n";
  12631. foreach (array_unique($problems) as $problem) {
  12632. $text .= " Problem ".($i++).$problem;
  12633. }
  12634. $hints = array();
  12635. if (!$isDevExtraction && (strpos($text, 'could not be found') || strpos($text, 'no matching package found'))) {
  12636. $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.";
  12637. }
  12638. if ($hasExtensionProblems) {
  12639. $hints[] = $this->createExtensionHint();
  12640. }
  12641. if ($isCausedByLock && !$isDevExtraction && !$request->getUpdateAllowTransitiveRootDependencies()) {
  12642. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  12643. }
  12644. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match') && strpos($text, '- ocramius/package-versions')) {
  12645. $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+.";
  12646. }
  12647. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  12648. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  12649. $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.";
  12650. }
  12651. }
  12652. if ($hints) {
  12653. $text .= "\n" . implode("\n\n", $hints);
  12654. }
  12655. return $text;
  12656. }
  12657. public function getProblems()
  12658. {
  12659. return $this->problems;
  12660. }
  12661. private function createExtensionHint()
  12662. {
  12663. $paths = IniHelper::getAll();
  12664. if (count($paths) === 1 && empty($paths[0])) {
  12665. return '';
  12666. }
  12667. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  12668. $text .= implode("\n - ", $paths);
  12669. $text .= "\nYou can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.";
  12670. return $text;
  12671. }
  12672. private function hasExtensionProblems(array $reasonSets)
  12673. {
  12674. foreach ($reasonSets as $reasonSet) {
  12675. foreach ($reasonSet as $rule) {
  12676. $required = $rule->getRequiredPackage();
  12677. if (null !== $required && 0 === strpos($required, 'ext-')) {
  12678. return true;
  12679. }
  12680. }
  12681. }
  12682. return false;
  12683. }
  12684. }
  12685. <?php
  12686. namespace Composer\DependencyResolver;
  12687. use Composer\Package\AliasPackage;
  12688. use Composer\Package\Link;
  12689. use Composer\Package\PackageInterface;
  12690. use Composer\Repository\PlatformRepository;
  12691. use Composer\DependencyResolver\Operation\OperationInterface;
  12692. class Transaction
  12693. {
  12694. protected $operations;
  12695. protected $presentPackages;
  12696. protected $resultPackageMap;
  12697. protected $resultPackagesByName = array();
  12698. public function __construct($presentPackages, $resultPackages)
  12699. {
  12700. $this->presentPackages = $presentPackages;
  12701. $this->setResultPackageMaps($resultPackages);
  12702. $this->operations = $this->calculateOperations();
  12703. }
  12704. public function getOperations()
  12705. {
  12706. return $this->operations;
  12707. }
  12708. private function setResultPackageMaps($resultPackages)
  12709. {
  12710. $packageSort = function (PackageInterface $a, PackageInterface $b) {
  12711. if ($a->getName() == $b->getName()) {
  12712. if ($a instanceof AliasPackage != $b instanceof AliasPackage) {
  12713. return $a instanceof AliasPackage ? -1 : 1;
  12714. }
  12715. return strcmp($b->getVersion(), $a->getVersion());
  12716. }
  12717. return strcmp($b->getName(), $a->getName());
  12718. };
  12719. $this->resultPackageMap = array();
  12720. foreach ($resultPackages as $package) {
  12721. $this->resultPackageMap[spl_object_hash($package)] = $package;
  12722. foreach ($package->getNames() as $name) {
  12723. $this->resultPackagesByName[$name][] = $package;
  12724. }
  12725. }
  12726. uasort($this->resultPackageMap, $packageSort);
  12727. foreach ($this->resultPackagesByName as $name => $packages) {
  12728. uasort($this->resultPackagesByName[$name], $packageSort);
  12729. }
  12730. }
  12731. protected function calculateOperations()
  12732. {
  12733. $operations = array();
  12734. $presentPackageMap = array();
  12735. $removeMap = array();
  12736. $presentAliasMap = array();
  12737. $removeAliasMap = array();
  12738. foreach ($this->presentPackages as $package) {
  12739. if ($package instanceof AliasPackage) {
  12740. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  12741. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  12742. } else {
  12743. $presentPackageMap[$package->getName()] = $package;
  12744. $removeMap[$package->getName()] = $package;
  12745. }
  12746. }
  12747. $stack = $this->getRootPackages();
  12748. $visited = array();
  12749. $processed = array();
  12750. while (!empty($stack)) {
  12751. $package = array_pop($stack);
  12752. if (isset($processed[spl_object_hash($package)])) {
  12753. continue;
  12754. }
  12755. if (!isset($visited[spl_object_hash($package)])) {
  12756. $visited[spl_object_hash($package)] = true;
  12757. $stack[] = $package;
  12758. if ($package instanceof AliasPackage) {
  12759. $stack[] = $package->getAliasOf();
  12760. } else {
  12761. foreach ($package->getRequires() as $link) {
  12762. $possibleRequires = $this->getProvidersInResult($link);
  12763. foreach ($possibleRequires as $require) {
  12764. $stack[] = $require;
  12765. }
  12766. }
  12767. }
  12768. } elseif (!isset($processed[spl_object_hash($package)])) {
  12769. $processed[spl_object_hash($package)] = true;
  12770. if ($package instanceof AliasPackage) {
  12771. $aliasKey = $package->getName().'::'.$package->getVersion();
  12772. if (isset($presentAliasMap[$aliasKey])) {
  12773. unset($removeAliasMap[$aliasKey]);
  12774. } else {
  12775. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  12776. }
  12777. } else {
  12778. if (isset($presentPackageMap[$package->getName()])) {
  12779. $source = $presentPackageMap[$package->getName()];
  12780. if ($package->getVersion() != $presentPackageMap[$package->getName()]->getVersion() ||
  12781. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  12782. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  12783. ) {
  12784. $operations[] = new Operation\UpdateOperation($source, $package);
  12785. }
  12786. unset($removeMap[$package->getName()]);
  12787. } else {
  12788. $operations[] = new Operation\InstallOperation($package);
  12789. unset($removeMap[$package->getName()]);
  12790. }
  12791. }
  12792. }
  12793. }
  12794. foreach ($removeMap as $name => $package) {
  12795. array_unshift($operations, new Operation\UninstallOperation($package));
  12796. }
  12797. foreach ($removeAliasMap as $nameVersion => $package) {
  12798. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  12799. }
  12800. $operations = $this->movePluginsToFront($operations);
  12801. $operations = $this->moveUninstallsToFront($operations);
  12802. return $this->operations = $operations;
  12803. }
  12804. protected function getRootPackages()
  12805. {
  12806. $roots = $this->resultPackageMap;
  12807. foreach ($this->resultPackageMap as $packageHash => $package) {
  12808. if (!isset($roots[$packageHash])) {
  12809. continue;
  12810. }
  12811. foreach ($package->getRequires() as $link) {
  12812. $possibleRequires = $this->getProvidersInResult($link);
  12813. foreach ($possibleRequires as $require) {
  12814. if ($require !== $package) {
  12815. unset($roots[spl_object_hash($require)]);
  12816. }
  12817. }
  12818. }
  12819. }
  12820. return $roots;
  12821. }
  12822. protected function getProvidersInResult(Link $link)
  12823. {
  12824. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  12825. return array();
  12826. }
  12827. return $this->resultPackagesByName[$link->getTarget()];
  12828. }
  12829. private function movePluginsToFront(array $operations)
  12830. {
  12831. $dlModifyingPluginsNoDeps = array();
  12832. $dlModifyingPluginsWithDeps = array();
  12833. $dlModifyingPluginRequires = array();
  12834. $pluginsNoDeps = array();
  12835. $pluginsWithDeps = array();
  12836. $pluginRequires = array();
  12837. foreach (array_reverse($operations, true) as $idx => $op) {
  12838. if ($op instanceof Operation\InstallOperation) {
  12839. $package = $op->getPackage();
  12840. } elseif ($op instanceof Operation\UpdateOperation) {
  12841. $package = $op->getTargetPackage();
  12842. } else {
  12843. continue;
  12844. }
  12845. $isDownloadsModifyingPlugin = $package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true;
  12846. if ($isDownloadsModifyingPlugin || count(array_intersect($package->getNames(), $dlModifyingPluginRequires))) {
  12847. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  12848. return !PlatformRepository::isPlatformPackage($req);
  12849. });
  12850. if ($isDownloadsModifyingPlugin && !count($requires)) {
  12851. array_unshift($dlModifyingPluginsNoDeps, $op);
  12852. } else {
  12853. $dlModifyingPluginRequires = array_merge($dlModifyingPluginRequires, $requires);
  12854. array_unshift($dlModifyingPluginsWithDeps, $op);
  12855. }
  12856. unset($operations[$idx]);
  12857. continue;
  12858. }
  12859. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  12860. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  12861. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  12862. return !PlatformRepository::isPlatformPackage($req);
  12863. });
  12864. if ($isPlugin && !count($requires)) {
  12865. array_unshift($pluginsNoDeps, $op);
  12866. } else {
  12867. $pluginRequires = array_merge($pluginRequires, $requires);
  12868. array_unshift($pluginsWithDeps, $op);
  12869. }
  12870. unset($operations[$idx]);
  12871. }
  12872. }
  12873. return array_merge($dlModifyingPluginsNoDeps, $dlModifyingPluginsWithDeps, $pluginsNoDeps, $pluginsWithDeps, $operations);
  12874. }
  12875. private function moveUninstallsToFront(array $operations)
  12876. {
  12877. $uninstOps = array();
  12878. foreach ($operations as $idx => $op) {
  12879. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  12880. $uninstOps[] = $op;
  12881. unset($operations[$idx]);
  12882. }
  12883. }
  12884. return array_merge($uninstOps, $operations);
  12885. }
  12886. }
  12887. <?php
  12888. namespace Composer\Downloader;
  12889. use Composer\Package\PackageInterface;
  12890. use Symfony\Component\Finder\Finder;
  12891. use React\Promise\PromiseInterface;
  12892. use Composer\DependencyResolver\Operation\InstallOperation;
  12893. abstract class ArchiveDownloader extends FileDownloader
  12894. {
  12895. public $cleanupExecuted = array();
  12896. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12897. {
  12898. unset($this->cleanupExecuted[$package->getName()]);
  12899. return parent::prepare($type, $package, $path, $prevPackage);
  12900. }
  12901. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12902. {
  12903. $this->cleanupExecuted[$package->getName()] = true;
  12904. return parent::cleanup($type, $package, $path, $prevPackage);
  12905. }
  12906. public function install(PackageInterface $package, $path, $output = true)
  12907. {
  12908. if ($output) {
  12909. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  12910. }
  12911. $vendorDir = $this->config->get('vendor-dir');
  12912. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  12913. $this->filesystem->emptyDirectory($path);
  12914. }
  12915. do {
  12916. $temporaryDir = $vendorDir.'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  12917. } while (is_dir($temporaryDir));
  12918. $this->addCleanupPath($package, $temporaryDir);
  12919. if (!is_dir($path) || realpath($path) !== getcwd()) {
  12920. $this->addCleanupPath($package, $path);
  12921. }
  12922. $this->filesystem->ensureDirectoryExists($temporaryDir);
  12923. $fileName = $this->getFileName($package, $path);
  12924. $filesystem = $this->filesystem;
  12925. $self = $this;
  12926. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package, $self) {
  12927. $self->clearLastCacheWrite($package);
  12928. $filesystem->removeDirectory($temporaryDir);
  12929. if (is_dir($path) && realpath($path) !== getcwd()) {
  12930. $filesystem->removeDirectory($path);
  12931. }
  12932. $self->removeCleanupPath($package, $temporaryDir);
  12933. $self->removeCleanupPath($package, realpath($path));
  12934. };
  12935. $promise = null;
  12936. try {
  12937. $promise = $this->extract($package, $fileName, $temporaryDir);
  12938. } catch (\Exception $e) {
  12939. $cleanup();
  12940. throw $e;
  12941. }
  12942. if (!$promise instanceof PromiseInterface) {
  12943. $promise = \React\Promise\resolve();
  12944. }
  12945. return $promise->then(function () use ($self, $package, $filesystem, $fileName, $temporaryDir, $path) {
  12946. $filesystem->unlink($fileName);
  12947. $getFolderContent = function ($dir) {
  12948. $finder = Finder::create()
  12949. ->ignoreVCS(false)
  12950. ->ignoreDotFiles(false)
  12951. ->notName('.DS_Store')
  12952. ->depth(0)
  12953. ->in($dir);
  12954. return iterator_to_array($finder);
  12955. };
  12956. $renameRecursively = null;
  12957. $renameRecursively = function ($from, $to) use ($filesystem, $getFolderContent, $package, &$renameRecursively) {
  12958. $contentDir = $getFolderContent($from);
  12959. foreach ($contentDir as $file) {
  12960. $file = (string) $file;
  12961. if (is_dir($to . '/' . basename($file))) {
  12962. if (!is_dir($file)) {
  12963. throw new \RuntimeException('Installing '.$package.' would lead to overwriting the '.$to.'/'.basename($file).' directory with a file from the package, invalid operation.');
  12964. }
  12965. $renameRecursively($file, $to . '/' . basename($file));
  12966. } else {
  12967. $filesystem->rename($file, $to . '/' . basename($file));
  12968. }
  12969. }
  12970. };
  12971. $renameAsOne = false;
  12972. if (!file_exists($path)) {
  12973. $renameAsOne = true;
  12974. } elseif ($filesystem->isDirEmpty($path)) {
  12975. try {
  12976. if ($filesystem->removeDirectoryPhp($path)) {
  12977. $renameAsOne = true;
  12978. }
  12979. } catch (\RuntimeException $e) {
  12980. }
  12981. }
  12982. $contentDir = $getFolderContent($temporaryDir);
  12983. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir(reset($contentDir));
  12984. if ($renameAsOne) {
  12985. if ($singleDirAtTopLevel) {
  12986. $extractedDir = (string) reset($contentDir);
  12987. } else {
  12988. $extractedDir = $temporaryDir;
  12989. }
  12990. $filesystem->rename($extractedDir, $path);
  12991. } else {
  12992. $from = $temporaryDir;
  12993. if ($singleDirAtTopLevel) {
  12994. $from = (string) reset($contentDir);
  12995. }
  12996. $renameRecursively($from, $path);
  12997. }
  12998. $promise = $filesystem->removeDirectoryAsync($temporaryDir);
  12999. return $promise->then(function () use ($self, $package, $path, $temporaryDir) {
  13000. $self->removeCleanupPath($package, $temporaryDir);
  13001. $self->removeCleanupPath($package, $path);
  13002. });
  13003. }, function ($e) use ($cleanup) {
  13004. $cleanup();
  13005. throw $e;
  13006. });
  13007. }
  13008. protected function getInstallOperationAppendix(PackageInterface $package, $path)
  13009. {
  13010. return ': Extracting archive';
  13011. }
  13012. abstract protected function extract(PackageInterface $package, $file, $path);
  13013. }
  13014. <?php
  13015. namespace Composer\Downloader;
  13016. use Composer\Package\PackageInterface;
  13017. interface ChangeReportInterface
  13018. {
  13019. public function getLocalChanges(PackageInterface $package, $path);
  13020. }
  13021. <?php
  13022. namespace Composer\Downloader;
  13023. use Composer\Package\PackageInterface;
  13024. use Composer\IO\IOInterface;
  13025. use Composer\Util\Filesystem;
  13026. use Composer\Exception\IrrecoverableDownloadException;
  13027. use React\Promise\PromiseInterface;
  13028. class DownloadManager
  13029. {
  13030. private $io;
  13031. private $preferDist = false;
  13032. private $preferSource;
  13033. private $packagePreferences = array();
  13034. private $filesystem;
  13035. private $downloaders = array();
  13036. public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
  13037. {
  13038. $this->io = $io;
  13039. $this->preferSource = $preferSource;
  13040. $this->filesystem = $filesystem ?: new Filesystem();
  13041. }
  13042. public function setPreferSource($preferSource)
  13043. {
  13044. $this->preferSource = $preferSource;
  13045. return $this;
  13046. }
  13047. public function setPreferDist($preferDist)
  13048. {
  13049. $this->preferDist = $preferDist;
  13050. return $this;
  13051. }
  13052. public function setPreferences(array $preferences)
  13053. {
  13054. $this->packagePreferences = $preferences;
  13055. return $this;
  13056. }
  13057. public function setDownloader($type, DownloaderInterface $downloader)
  13058. {
  13059. $type = strtolower($type);
  13060. $this->downloaders[$type] = $downloader;
  13061. return $this;
  13062. }
  13063. public function getDownloader($type)
  13064. {
  13065. $type = strtolower($type);
  13066. if (!isset($this->downloaders[$type])) {
  13067. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  13068. }
  13069. return $this->downloaders[$type];
  13070. }
  13071. public function getDownloaderForPackage(PackageInterface $package)
  13072. {
  13073. $installationSource = $package->getInstallationSource();
  13074. if ('metapackage' === $package->getType()) {
  13075. return null;
  13076. }
  13077. if ('dist' === $installationSource) {
  13078. $downloader = $this->getDownloader($package->getDistType());
  13079. } elseif ('source' === $installationSource) {
  13080. $downloader = $this->getDownloader($package->getSourceType());
  13081. } else {
  13082. throw new \InvalidArgumentException(
  13083. 'Package '.$package.' does not have an installation source set'
  13084. );
  13085. }
  13086. if ($installationSource !== $downloader->getInstallationSource()) {
  13087. throw new \LogicException(sprintf(
  13088. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  13089. get_class($downloader),
  13090. $downloader->getInstallationSource(),
  13091. $installationSource,
  13092. $package
  13093. ));
  13094. }
  13095. return $downloader;
  13096. }
  13097. public function getDownloaderType(DownloaderInterface $downloader)
  13098. {
  13099. return array_search($downloader, $this->downloaders);
  13100. }
  13101. public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  13102. {
  13103. $targetDir = $this->normalizeTargetDir($targetDir);
  13104. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  13105. $sources = $this->getAvailableSources($package, $prevPackage);
  13106. $io = $this->io;
  13107. $self = $this;
  13108. $download = function ($retry = false) use (&$sources, $io, $package, $self, $targetDir, &$download, $prevPackage) {
  13109. $source = array_shift($sources);
  13110. if ($retry) {
  13111. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  13112. }
  13113. $package->setInstallationSource($source);
  13114. $downloader = $self->getDownloaderForPackage($package);
  13115. if (!$downloader) {
  13116. return \React\Promise\resolve();
  13117. }
  13118. $handleError = function ($e) use ($sources, $source, $package, $io, $download) {
  13119. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  13120. if (!$sources) {
  13121. throw $e;
  13122. }
  13123. $io->writeError(
  13124. ' <warning>Failed to download '.
  13125. $package->getPrettyName().
  13126. ' from ' . $source . ': '.
  13127. $e->getMessage().'</warning>'
  13128. );
  13129. return $download(true);
  13130. }
  13131. throw $e;
  13132. };
  13133. try {
  13134. $result = $downloader->download($package, $targetDir, $prevPackage);
  13135. } catch (\Exception $e) {
  13136. return $handleError($e);
  13137. }
  13138. if (!$result instanceof PromiseInterface) {
  13139. return \React\Promise\resolve($result);
  13140. }
  13141. $res = $result->then(function ($res) {
  13142. return $res;
  13143. }, $handleError);
  13144. return $res;
  13145. };
  13146. return $download();
  13147. }
  13148. public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  13149. {
  13150. $targetDir = $this->normalizeTargetDir($targetDir);
  13151. $downloader = $this->getDownloaderForPackage($package);
  13152. if ($downloader) {
  13153. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  13154. }
  13155. return \React\Promise\resolve();
  13156. }
  13157. public function install(PackageInterface $package, $targetDir)
  13158. {
  13159. $targetDir = $this->normalizeTargetDir($targetDir);
  13160. $downloader = $this->getDownloaderForPackage($package);
  13161. if ($downloader) {
  13162. return $downloader->install($package, $targetDir);
  13163. }
  13164. return \React\Promise\resolve();
  13165. }
  13166. public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
  13167. {
  13168. $targetDir = $this->normalizeTargetDir($targetDir);
  13169. $downloader = $this->getDownloaderForPackage($target);
  13170. $initialDownloader = $this->getDownloaderForPackage($initial);
  13171. if (!$initialDownloader && !$downloader) {
  13172. return \React\Promise\resolve();
  13173. }
  13174. if (!$downloader) {
  13175. return $initialDownloader->remove($initial, $targetDir);
  13176. }
  13177. $initialType = $this->getDownloaderType($initialDownloader);
  13178. $targetType = $this->getDownloaderType($downloader);
  13179. if ($initialType === $targetType) {
  13180. try {
  13181. return $downloader->update($initial, $target, $targetDir);
  13182. } catch (\RuntimeException $e) {
  13183. if (!$this->io->isInteractive()) {
  13184. throw $e;
  13185. }
  13186. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  13187. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  13188. throw $e;
  13189. }
  13190. }
  13191. }
  13192. $promise = $initialDownloader->remove($initial, $targetDir);
  13193. if ($promise) {
  13194. $self = $this;
  13195. return $promise->then(function ($res) use ($self, $target, $targetDir) {
  13196. return $self->install($target, $targetDir);
  13197. });
  13198. }
  13199. return $this->install($target, $targetDir);
  13200. }
  13201. public function remove(PackageInterface $package, $targetDir)
  13202. {
  13203. $targetDir = $this->normalizeTargetDir($targetDir);
  13204. $downloader = $this->getDownloaderForPackage($package);
  13205. if ($downloader) {
  13206. return $downloader->remove($package, $targetDir);
  13207. }
  13208. return \React\Promise\resolve();
  13209. }
  13210. public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  13211. {
  13212. $targetDir = $this->normalizeTargetDir($targetDir);
  13213. $downloader = $this->getDownloaderForPackage($package);
  13214. if ($downloader) {
  13215. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  13216. }
  13217. return \React\Promise\resolve();
  13218. }
  13219. protected function resolvePackageInstallPreference(PackageInterface $package)
  13220. {
  13221. foreach ($this->packagePreferences as $pattern => $preference) {
  13222. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  13223. if (preg_match($pattern, $package->getName())) {
  13224. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  13225. return 'dist';
  13226. }
  13227. return 'source';
  13228. }
  13229. }
  13230. return $package->isDev() ? 'source' : 'dist';
  13231. }
  13232. private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null)
  13233. {
  13234. $sourceType = $package->getSourceType();
  13235. $distType = $package->getDistType();
  13236. $sources = array();
  13237. if ($sourceType) {
  13238. $sources[] = 'source';
  13239. }
  13240. if ($distType) {
  13241. $sources[] = 'dist';
  13242. }
  13243. if (empty($sources)) {
  13244. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  13245. }
  13246. if (
  13247. $prevPackage
  13248. && in_array($prevPackage->getInstallationSource(), $sources, true)
  13249. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  13250. ) {
  13251. $prevSource = $prevPackage->getInstallationSource();
  13252. usort($sources, function ($a, $b) use ($prevSource) {
  13253. return $a === $prevSource ? -1 : 1;
  13254. });
  13255. return $sources;
  13256. }
  13257. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  13258. $sources = array_reverse($sources);
  13259. }
  13260. return $sources;
  13261. }
  13262. private function normalizeTargetDir($dir)
  13263. {
  13264. if ($dir === '\\' || $dir === '/') {
  13265. return $dir;
  13266. }
  13267. return rtrim($dir, '\\/');
  13268. }
  13269. }
  13270. <?php
  13271. namespace Composer\Downloader;
  13272. use Composer\Package\PackageInterface;
  13273. use React\Promise\PromiseInterface;
  13274. interface DownloaderInterface
  13275. {
  13276. public function getInstallationSource();
  13277. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null);
  13278. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  13279. public function install(PackageInterface $package, $path);
  13280. public function update(PackageInterface $initial, PackageInterface $target, $path);
  13281. public function remove(PackageInterface $package, $path);
  13282. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  13283. }
  13284. <?php
  13285. namespace Composer\Downloader;
  13286. use Composer\Package\PackageInterface;
  13287. interface DvcsDownloaderInterface
  13288. {
  13289. public function getUnpushedChanges(PackageInterface $package, $path);
  13290. }
  13291. <?php
  13292. namespace Composer\Downloader;
  13293. use Composer\Config;
  13294. use Composer\Cache;
  13295. use Composer\IO\IOInterface;
  13296. use Composer\IO\NullIO;
  13297. use Composer\Exception\IrrecoverableDownloadException;
  13298. use Composer\Package\Comparer\Comparer;
  13299. use Composer\DependencyResolver\Operation\UpdateOperation;
  13300. use Composer\DependencyResolver\Operation\InstallOperation;
  13301. use Composer\DependencyResolver\Operation\UninstallOperation;
  13302. use Composer\Package\PackageInterface;
  13303. use Composer\Plugin\PluginEvents;
  13304. use Composer\Plugin\PostFileDownloadEvent;
  13305. use Composer\Plugin\PreFileDownloadEvent;
  13306. use Composer\EventDispatcher\EventDispatcher;
  13307. use Composer\Util\Filesystem;
  13308. use Composer\Util\Silencer;
  13309. use Composer\Util\HttpDownloader;
  13310. use Composer\Util\Url as UrlUtil;
  13311. use Composer\Util\ProcessExecutor;
  13312. use React\Promise\PromiseInterface;
  13313. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  13314. {
  13315. protected $io;
  13316. protected $config;
  13317. protected $httpDownloader;
  13318. protected $filesystem;
  13319. protected $cache;
  13320. protected $eventDispatcher;
  13321. protected $process;
  13322. public static $downloadMetadata = array();
  13323. public $lastCacheWrites = array();
  13324. private $additionalCleanupPaths = array();
  13325. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null)
  13326. {
  13327. $this->io = $io;
  13328. $this->config = $config;
  13329. $this->eventDispatcher = $eventDispatcher;
  13330. $this->httpDownloader = $httpDownloader;
  13331. $this->cache = $cache;
  13332. $this->process = $process ?: new ProcessExecutor($io);
  13333. $this->filesystem = $filesystem ?: new Filesystem($this->process);
  13334. if ($this->cache && $this->cache->gcIsNecessary()) {
  13335. $this->io->writeError('Running cache garbage collection', true, IOInterface::VERY_VERBOSE);
  13336. $this->cache->gc((int) $config->get('cache-files-ttl'), (int) $config->get('cache-files-maxsize'));
  13337. }
  13338. }
  13339. public function getInstallationSource()
  13340. {
  13341. return 'dist';
  13342. }
  13343. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  13344. {
  13345. if (!$package->getDistUrl()) {
  13346. throw new \InvalidArgumentException('The given package is missing url information');
  13347. }
  13348. $cacheKeyGenerator = function (PackageInterface $package, $key) {
  13349. $cacheKey = sha1($key);
  13350. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  13351. };
  13352. $retries = 3;
  13353. $distUrls = $package->getDistUrls();
  13354. $urls = array();
  13355. foreach ($distUrls as $index => $url) {
  13356. $processedUrl = $this->processUrl($package, $url);
  13357. $urls[$index] = array(
  13358. 'base' => $url,
  13359. 'processed' => $processedUrl,
  13360. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
  13361. );
  13362. }
  13363. $fileName = $this->getFileName($package, $path);
  13364. $this->filesystem->ensureDirectoryExists($path);
  13365. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  13366. $io = $this->io;
  13367. $cache = $this->cache;
  13368. $httpDownloader = $this->httpDownloader;
  13369. $eventDispatcher = $this->eventDispatcher;
  13370. $filesystem = $this->filesystem;
  13371. $self = $this;
  13372. $accept = null;
  13373. $reject = null;
  13374. $download = function () use ($io, $output, $httpDownloader, $cache, $cacheKeyGenerator, $eventDispatcher, $package, $fileName, &$urls, &$accept, &$reject, $self) {
  13375. $url = reset($urls);
  13376. $index = key($urls);
  13377. if ($eventDispatcher) {
  13378. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $httpDownloader, $url['processed'], 'package', $package);
  13379. $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  13380. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  13381. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  13382. } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  13383. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  13384. }
  13385. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  13386. }
  13387. $urls[$index] = $url;
  13388. $checksum = $package->getDistSha1Checksum();
  13389. $cacheKey = $url['cacheKey'];
  13390. if ($cache && (!$checksum || $checksum === $cache->sha1($cacheKey)) && $cache->copyTo($cacheKey, $fileName)) {
  13391. if ($output) {
  13392. $io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  13393. }
  13394. if (!$cache->isReadOnly()) {
  13395. $self->lastCacheWrites[$package->getName()] = $cacheKey;
  13396. }
  13397. $result = \React\Promise\resolve($fileName);
  13398. } else {
  13399. if ($output) {
  13400. $io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  13401. }
  13402. $result = $httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  13403. ->then($accept, $reject);
  13404. }
  13405. return $result->then(function ($result) use ($fileName, $checksum, $url, $package, $eventDispatcher) {
  13406. if (null === $result) {
  13407. return $fileName;
  13408. }
  13409. if (!file_exists($fileName)) {
  13410. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  13411. .' directory is writable and you have internet connectivity');
  13412. }
  13413. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  13414. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  13415. }
  13416. if ($eventDispatcher) {
  13417. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], 'package', $package);
  13418. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  13419. }
  13420. return $fileName;
  13421. });
  13422. };
  13423. $accept = function ($response) use ($cache, $package, $fileName, $self, &$urls) {
  13424. $url = reset($urls);
  13425. $cacheKey = $url['cacheKey'];
  13426. FileDownloader::$downloadMetadata[$package->getName()] = @filesize($fileName) ?: $response->getHeader('Content-Length') ?: '?';
  13427. if ($cache && !$cache->isReadOnly()) {
  13428. $self->lastCacheWrites[$package->getName()] = $cacheKey;
  13429. $cache->copyFrom($cacheKey, $fileName);
  13430. }
  13431. $response->collect();
  13432. return $fileName;
  13433. };
  13434. $reject = function ($e) use ($io, &$urls, $download, $fileName, $package, &$retries, $filesystem, $self) {
  13435. if (file_exists($fileName)) {
  13436. $filesystem->unlink($fileName);
  13437. }
  13438. $self->clearLastCacheWrite($package);
  13439. if ($e instanceof IrrecoverableDownloadException) {
  13440. throw $e;
  13441. }
  13442. if ($e instanceof MaxFileSizeExceededException) {
  13443. throw $e;
  13444. }
  13445. if ($e instanceof TransportException) {
  13446. if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
  13447. $retries = 0;
  13448. }
  13449. }
  13450. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  13451. $retries = 0;
  13452. $urls = array();
  13453. }
  13454. if ($retries) {
  13455. usleep(500000);
  13456. $retries--;
  13457. return $download();
  13458. }
  13459. array_shift($urls);
  13460. if ($urls) {
  13461. if ($io->isDebug()) {
  13462. $io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  13463. $io->writeError(' Trying the next URL for '.$package->getName());
  13464. } else {
  13465. $io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  13466. }
  13467. $retries = 3;
  13468. usleep(100000);
  13469. return $download();
  13470. }
  13471. throw $e;
  13472. };
  13473. return $download();
  13474. }
  13475. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13476. {
  13477. return \React\Promise\resolve();
  13478. }
  13479. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13480. {
  13481. $fileName = $this->getFileName($package, $path);
  13482. if (file_exists($fileName)) {
  13483. $this->filesystem->unlink($fileName);
  13484. }
  13485. $dirsToCleanUp = array(
  13486. $this->config->get('vendor-dir').'/composer/',
  13487. $this->config->get('vendor-dir'),
  13488. $path,
  13489. );
  13490. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  13491. foreach ($this->additionalCleanupPaths[$package->getName()] as $path) {
  13492. $this->filesystem->remove($path);
  13493. }
  13494. }
  13495. foreach ($dirsToCleanUp as $dir) {
  13496. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== getcwd()) {
  13497. $this->filesystem->removeDirectoryPhp($dir);
  13498. }
  13499. }
  13500. return \React\Promise\resolve();
  13501. }
  13502. public function install(PackageInterface $package, $path, $output = true)
  13503. {
  13504. if ($output) {
  13505. $this->io->writeError(" - " . InstallOperation::format($package));
  13506. }
  13507. $this->filesystem->emptyDirectory($path);
  13508. $this->filesystem->ensureDirectoryExists($path);
  13509. $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
  13510. if ($package->getBinaries()) {
  13511. foreach ($package->getBinaries() as $bin) {
  13512. if (file_exists($path . '/' . $bin) && !is_executable($path . '/' . $bin)) {
  13513. Silencer::call('chmod', $path . '/' . $bin, 0777 & ~umask());
  13514. }
  13515. }
  13516. }
  13517. return \React\Promise\resolve();
  13518. }
  13519. public function clearLastCacheWrite(PackageInterface $package)
  13520. {
  13521. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  13522. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  13523. unset($this->lastCacheWrites[$package->getName()]);
  13524. }
  13525. }
  13526. public function addCleanupPath(PackageInterface $package, $path)
  13527. {
  13528. $this->additionalCleanupPaths[$package->getName()][] = $path;
  13529. }
  13530. public function removeCleanupPath(PackageInterface $package, $path)
  13531. {
  13532. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  13533. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
  13534. if (false !== $idx) {
  13535. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  13536. }
  13537. }
  13538. }
  13539. public function update(PackageInterface $initial, PackageInterface $target, $path)
  13540. {
  13541. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . $this->getInstallOperationAppendix($target, $path));
  13542. $promise = $this->remove($initial, $path, false);
  13543. if (!$promise instanceof PromiseInterface) {
  13544. $promise = \React\Promise\resolve();
  13545. }
  13546. $self = $this;
  13547. $io = $this->io;
  13548. return $promise->then(function () use ($self, $target, $path) {
  13549. $promise = $self->install($target, $path, false);
  13550. return $promise;
  13551. });
  13552. }
  13553. public function remove(PackageInterface $package, $path, $output = true)
  13554. {
  13555. if ($output) {
  13556. $this->io->writeError(" - " . UninstallOperation::format($package));
  13557. }
  13558. $promise = $this->filesystem->removeDirectoryAsync($path);
  13559. return $promise->then(function ($result) use ($path) {
  13560. if (!$result) {
  13561. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  13562. }
  13563. });
  13564. }
  13565. protected function getFileName(PackageInterface $package, $path)
  13566. {
  13567. 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), '.');
  13568. }
  13569. protected function getInstallOperationAppendix(PackageInterface $package, $path)
  13570. {
  13571. return '';
  13572. }
  13573. protected function processUrl(PackageInterface $package, $url)
  13574. {
  13575. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  13576. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  13577. }
  13578. if ($package->getDistReference()) {
  13579. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  13580. }
  13581. return $url;
  13582. }
  13583. public function getLocalChanges(PackageInterface $package, $targetDir)
  13584. {
  13585. $prevIO = $this->io;
  13586. $this->io = new NullIO;
  13587. $this->io->loadConfiguration($this->config);
  13588. $e = null;
  13589. $output = '';
  13590. $targetDir = Filesystem::trimTrailingSlash($targetDir);
  13591. try {
  13592. if (is_dir($targetDir.'_compare')) {
  13593. $this->filesystem->removeDirectory($targetDir.'_compare');
  13594. }
  13595. $this->download($package, $targetDir.'_compare', null, false);
  13596. $this->httpDownloader->wait();
  13597. $this->install($package, $targetDir.'_compare', false);
  13598. $this->process->wait();
  13599. $comparer = new Comparer();
  13600. $comparer->setSource($targetDir.'_compare');
  13601. $comparer->setUpdate($targetDir);
  13602. $comparer->doCompare();
  13603. $output = $comparer->getChanged(true, true);
  13604. $this->filesystem->removeDirectory($targetDir.'_compare');
  13605. } catch (\Exception $e) {
  13606. }
  13607. $this->io = $prevIO;
  13608. if ($e) {
  13609. throw $e;
  13610. }
  13611. return trim($output);
  13612. }
  13613. }
  13614. <?php
  13615. namespace Composer\Downloader;
  13616. class FilesystemException extends \Exception
  13617. {
  13618. public function __construct($message = '', $code = 0, \Exception $previous = null)
  13619. {
  13620. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  13621. }
  13622. }
  13623. <?php
  13624. namespace Composer\Downloader;
  13625. use Composer\Package\PackageInterface;
  13626. use Composer\Util\ProcessExecutor;
  13627. class FossilDownloader extends VcsDownloader
  13628. {
  13629. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13630. {
  13631. return \React\Promise\resolve();
  13632. }
  13633. protected function doInstall(PackageInterface $package, $path, $url)
  13634. {
  13635. $this->config->prohibitUrlByConfig($url, $this->io);
  13636. $url = ProcessExecutor::escape($url);
  13637. $ref = ProcessExecutor::escape($package->getSourceReference());
  13638. $repoFile = $path . '.fossil';
  13639. $this->io->writeError("Cloning ".$package->getSourceReference());
  13640. $command = sprintf('fossil clone -- %s %s', $url, ProcessExecutor::escape($repoFile));
  13641. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  13642. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13643. }
  13644. $command = sprintf('fossil open --nested -- %s', ProcessExecutor::escape($repoFile));
  13645. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  13646. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13647. }
  13648. $command = sprintf('fossil update -- %s', $ref);
  13649. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  13650. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13651. }
  13652. return \React\Promise\resolve();
  13653. }
  13654. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13655. {
  13656. $this->config->prohibitUrlByConfig($url, $this->io);
  13657. $ref = ProcessExecutor::escape($target->getSourceReference());
  13658. $this->io->writeError(" Updating to ".$target->getSourceReference());
  13659. if (!$this->hasMetadataRepository($path)) {
  13660. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13661. }
  13662. $command = sprintf('fossil pull && fossil up %s', $ref);
  13663. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  13664. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13665. }
  13666. return \React\Promise\resolve();
  13667. }
  13668. public function getLocalChanges(PackageInterface $package, $path)
  13669. {
  13670. if (!$this->hasMetadataRepository($path)) {
  13671. return null;
  13672. }
  13673. $this->process->execute('fossil changes', $output, realpath($path));
  13674. return trim($output) ?: null;
  13675. }
  13676. protected function getCommitLogs($fromReference, $toReference, $path)
  13677. {
  13678. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  13679. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  13680. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13681. }
  13682. $log = '';
  13683. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  13684. foreach ($this->process->splitLines($output) as $line) {
  13685. if (preg_match($match, $line)) {
  13686. break;
  13687. }
  13688. $log .= $line;
  13689. }
  13690. return $log;
  13691. }
  13692. protected function hasMetadataRepository($path)
  13693. {
  13694. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  13695. }
  13696. }
  13697. <?php
  13698. namespace Composer\Downloader;
  13699. use Composer\Config;
  13700. use Composer\IO\IOInterface;
  13701. use Composer\Package\PackageInterface;
  13702. use Composer\Util\Filesystem;
  13703. use Composer\Util\Git as GitUtil;
  13704. use Composer\Util\Url;
  13705. use Composer\Util\Platform;
  13706. use Composer\Util\ProcessExecutor;
  13707. use Composer\Cache;
  13708. use React\Promise\PromiseInterface;
  13709. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  13710. {
  13711. private $hasStashedChanges = array();
  13712. private $hasDiscardedChanges = array();
  13713. private $gitUtil;
  13714. private $cachedPackages = array();
  13715. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  13716. {
  13717. parent::__construct($io, $config, $process, $fs);
  13718. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  13719. }
  13720. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13721. {
  13722. GitUtil::cleanEnv();
  13723. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  13724. $gitVersion = GitUtil::getVersion($this->process);
  13725. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  13726. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  13727. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  13728. $ref = $package->getSourceReference();
  13729. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref) && is_dir($cachePath)) {
  13730. $this->cachedPackages[$package->getId()][$ref] = true;
  13731. }
  13732. } elseif (null === $gitVersion) {
  13733. throw new \RuntimeException('git was not found in your PATH, skipping source download');
  13734. }
  13735. return \React\Promise\resolve();
  13736. }
  13737. protected function doInstall(PackageInterface $package, $path, $url)
  13738. {
  13739. GitUtil::cleanEnv();
  13740. $path = $this->normalizePath($path);
  13741. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  13742. $ref = $package->getSourceReference();
  13743. $flag = Platform::isWindows() ? '/D ' : '';
  13744. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  13745. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  13746. $command =
  13747. 'git clone --no-checkout %cachePath% %path% --dissociate --reference %cachePath% '
  13748. . '&& cd '.$flag.'%path% '
  13749. . '&& git remote set-url origin -- %sanitizedUrl% && git remote add composer -- %sanitizedUrl%';
  13750. } else {
  13751. $msg = "Cloning ".$this->getShortHash($ref);
  13752. $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%';
  13753. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  13754. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  13755. }
  13756. }
  13757. $this->io->writeError($msg);
  13758. $commandCallable = function ($url) use ($path, $command, $cachePath) {
  13759. return str_replace(
  13760. array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
  13761. array(
  13762. ProcessExecutor::escape($url),
  13763. ProcessExecutor::escape($path),
  13764. ProcessExecutor::escape($cachePath),
  13765. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  13766. ),
  13767. $command
  13768. );
  13769. };
  13770. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  13771. $sourceUrl = $package->getSourceUrl();
  13772. if ($url !== $sourceUrl && $sourceUrl !== null) {
  13773. $this->updateOriginUrl($path, $sourceUrl);
  13774. } else {
  13775. $this->setPushUrl($path, $url);
  13776. }
  13777. if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
  13778. if ($package->getDistReference() === $package->getSourceReference()) {
  13779. $package->setDistReference($newRef);
  13780. }
  13781. $package->setSourceReference($newRef);
  13782. }
  13783. return \React\Promise\resolve();
  13784. }
  13785. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13786. {
  13787. GitUtil::cleanEnv();
  13788. $path = $this->normalizePath($path);
  13789. if (!$this->hasMetadataRepository($path)) {
  13790. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13791. }
  13792. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  13793. $ref = $target->getSourceReference();
  13794. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  13795. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  13796. $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%';
  13797. } else {
  13798. $msg = "Checking out ".$this->getShortHash($ref);
  13799. $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%';
  13800. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  13801. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  13802. }
  13803. }
  13804. $this->io->writeError($msg);
  13805. $commandCallable = function ($url) use ($ref, $command, $cachePath) {
  13806. return str_replace(
  13807. array('%url%', '%ref%', '%cachePath%', '%sanitizedUrl%'),
  13808. array(
  13809. ProcessExecutor::escape($url),
  13810. ProcessExecutor::escape($ref.'^{commit}'),
  13811. ProcessExecutor::escape($cachePath),
  13812. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  13813. ),
  13814. $command
  13815. );
  13816. };
  13817. $this->gitUtil->runCommand($commandCallable, $url, $path);
  13818. if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
  13819. if ($target->getDistReference() === $target->getSourceReference()) {
  13820. $target->setDistReference($newRef);
  13821. }
  13822. $target->setSourceReference($newRef);
  13823. }
  13824. $updateOriginUrl = false;
  13825. if (
  13826. 0 === $this->process->execute('git remote -v', $output, $path)
  13827. && preg_match('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  13828. && preg_match('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  13829. ) {
  13830. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  13831. $updateOriginUrl = true;
  13832. }
  13833. }
  13834. if ($updateOriginUrl && $target->getSourceUrl() !== null) {
  13835. $this->updateOriginUrl($path, $target->getSourceUrl());
  13836. }
  13837. return \React\Promise\resolve();
  13838. }
  13839. public function getLocalChanges(PackageInterface $package, $path)
  13840. {
  13841. GitUtil::cleanEnv();
  13842. if (!$this->hasMetadataRepository($path)) {
  13843. return null;
  13844. }
  13845. $command = 'git status --porcelain --untracked-files=no';
  13846. if (0 !== $this->process->execute($command, $output, $path)) {
  13847. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13848. }
  13849. return trim($output) ?: null;
  13850. }
  13851. public function getUnpushedChanges(PackageInterface $package, $path)
  13852. {
  13853. GitUtil::cleanEnv();
  13854. $path = $this->normalizePath($path);
  13855. if (!$this->hasMetadataRepository($path)) {
  13856. return null;
  13857. }
  13858. $command = 'git show-ref --head -d';
  13859. if (0 !== $this->process->execute($command, $output, $path)) {
  13860. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13861. }
  13862. $refs = trim($output);
  13863. if (!preg_match('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  13864. return null;
  13865. }
  13866. $headRef = $match[1];
  13867. if (!preg_match_all('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  13868. return null;
  13869. }
  13870. $candidateBranches = $matches[1];
  13871. $branch = $candidateBranches[0];
  13872. $unpushedChanges = null;
  13873. $branchNotFoundError = false;
  13874. for ($i = 0; $i <= 1; $i++) {
  13875. $remoteBranches = array();
  13876. foreach ($candidateBranches as $candidate) {
  13877. if (preg_match_all('{^[a-f0-9]+ refs/remotes/((?:[^/]+)/'.preg_quote($candidate).')$}mi', $refs, $matches)) {
  13878. foreach ($matches[1] as $match) {
  13879. $branch = $candidate;
  13880. $remoteBranches[] = $match;
  13881. }
  13882. break;
  13883. }
  13884. }
  13885. if (!$remoteBranches) {
  13886. $unpushedChanges = 'Branch ' . $branch . ' could not be found on any remote and appears to be unpushed';
  13887. $branchNotFoundError = true;
  13888. } else {
  13889. if ($branchNotFoundError) {
  13890. $unpushedChanges = null;
  13891. }
  13892. foreach ($remoteBranches as $remoteBranch) {
  13893. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  13894. if (0 !== $this->process->execute($command, $output, $path)) {
  13895. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13896. }
  13897. $output = trim($output);
  13898. if ($unpushedChanges === null || strlen($output) < strlen($unpushedChanges)) {
  13899. $unpushedChanges = $output;
  13900. }
  13901. }
  13902. }
  13903. if ($unpushedChanges && $i === 0) {
  13904. $this->process->execute('git fetch --all', $output, $path);
  13905. $command = 'git show-ref --head -d';
  13906. if (0 !== $this->process->execute($command, $output, $path)) {
  13907. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13908. }
  13909. $refs = trim($output);
  13910. }
  13911. if (!$unpushedChanges) {
  13912. break;
  13913. }
  13914. }
  13915. return $unpushedChanges;
  13916. }
  13917. protected function cleanChanges(PackageInterface $package, $path, $update)
  13918. {
  13919. GitUtil::cleanEnv();
  13920. $path = $this->normalizePath($path);
  13921. $unpushed = $this->getUnpushedChanges($package, $path);
  13922. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  13923. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  13924. }
  13925. if (!$changes = $this->getLocalChanges($package, $path)) {
  13926. return \React\Promise\resolve();
  13927. }
  13928. if (!$this->io->isInteractive()) {
  13929. $discardChanges = $this->config->get('discard-changes');
  13930. if (true === $discardChanges) {
  13931. return $this->discardChanges($path);
  13932. }
  13933. if ('stash' === $discardChanges) {
  13934. if (!$update) {
  13935. return parent::cleanChanges($package, $path, $update);
  13936. }
  13937. return $this->stashChanges($path);
  13938. }
  13939. return parent::cleanChanges($package, $path, $update);
  13940. }
  13941. $changes = array_map(function ($elem) {
  13942. return ' '.$elem;
  13943. }, preg_split('{\s*\r?\n\s*}', $changes));
  13944. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  13945. $this->io->writeError(array_slice($changes, 0, 10));
  13946. if (count($changes) > 10) {
  13947. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  13948. }
  13949. while (true) {
  13950. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  13951. case 'y':
  13952. $this->discardChanges($path);
  13953. break 2;
  13954. case 's':
  13955. if (!$update) {
  13956. goto help;
  13957. }
  13958. $this->stashChanges($path);
  13959. break 2;
  13960. case 'n':
  13961. throw new \RuntimeException('Update aborted');
  13962. case 'v':
  13963. $this->io->writeError($changes);
  13964. break;
  13965. case 'd':
  13966. $this->viewDiff($path);
  13967. break;
  13968. case '?':
  13969. default:
  13970. help :
  13971. $this->io->writeError(array(
  13972. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  13973. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  13974. ' v - view modified files',
  13975. ' d - view local modifications (diff)',
  13976. ));
  13977. if ($update) {
  13978. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  13979. }
  13980. $this->io->writeError(' ? - print help');
  13981. break;
  13982. }
  13983. }
  13984. return \React\Promise\resolve();
  13985. }
  13986. protected function reapplyChanges($path)
  13987. {
  13988. $path = $this->normalizePath($path);
  13989. if (!empty($this->hasStashedChanges[$path])) {
  13990. unset($this->hasStashedChanges[$path]);
  13991. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  13992. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  13993. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  13994. }
  13995. }
  13996. unset($this->hasDiscardedChanges[$path]);
  13997. }
  13998. protected function updateToCommit($path, $reference, $branch, $date)
  13999. {
  14000. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
  14001. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  14002. $branch = preg_replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch);
  14003. $branches = null;
  14004. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  14005. $branches = $output;
  14006. }
  14007. $gitRef = $reference;
  14008. if (!preg_match('{^[a-f0-9]{40}$}', $reference)
  14009. && $branches
  14010. && preg_match('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  14011. ) {
  14012. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  14013. if (0 === $this->process->execute($command, $output, $path)) {
  14014. return null;
  14015. }
  14016. }
  14017. if (preg_match('{^[a-f0-9]{40}$}', $reference)) {
  14018. if (!preg_match('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && preg_match('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  14019. $branch = 'v' . $branch;
  14020. }
  14021. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  14022. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  14023. $resetCommand = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  14024. if (0 === $this->process->execute("($command || $fallbackCommand) && $resetCommand", $output, $path)) {
  14025. return null;
  14026. }
  14027. }
  14028. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  14029. if (0 === $this->process->execute($command, $output, $path)) {
  14030. return null;
  14031. }
  14032. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  14033. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  14034. }
  14035. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()));
  14036. }
  14037. protected function updateOriginUrl($path, $url)
  14038. {
  14039. $this->process->execute(sprintf('git remote set-url origin -- %s', ProcessExecutor::escape($url)), $output, $path);
  14040. $this->setPushUrl($path, $url);
  14041. }
  14042. protected function setPushUrl($path, $url)
  14043. {
  14044. if (preg_match('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  14045. $protocols = $this->config->get('github-protocols');
  14046. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  14047. if (!in_array('ssh', $protocols, true)) {
  14048. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  14049. }
  14050. $cmd = sprintf('git remote set-url --push origin -- %s', ProcessExecutor::escape($pushUrl));
  14051. $this->process->execute($cmd, $ignoredOutput, $path);
  14052. }
  14053. }
  14054. protected function getCommitLogs($fromReference, $toReference, $path)
  14055. {
  14056. $path = $this->normalizePath($path);
  14057. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  14058. if (0 !== $this->process->execute($command, $output, $path)) {
  14059. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14060. }
  14061. return $output;
  14062. }
  14063. protected function discardChanges($path)
  14064. {
  14065. $path = $this->normalizePath($path);
  14066. if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
  14067. throw new \RuntimeException("Could not reset changes\n\n:".$output);
  14068. }
  14069. $this->hasDiscardedChanges[$path] = true;
  14070. return \React\Promise\resolve();
  14071. }
  14072. protected function stashChanges($path)
  14073. {
  14074. $path = $this->normalizePath($path);
  14075. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  14076. throw new \RuntimeException("Could not stash changes\n\n:".$output);
  14077. }
  14078. $this->hasStashedChanges[$path] = true;
  14079. return \React\Promise\resolve();
  14080. }
  14081. protected function viewDiff($path)
  14082. {
  14083. $path = $this->normalizePath($path);
  14084. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  14085. throw new \RuntimeException("Could not view diff\n\n:".$output);
  14086. }
  14087. $this->io->writeError($output);
  14088. }
  14089. protected function normalizePath($path)
  14090. {
  14091. if (Platform::isWindows() && strlen($path) > 0) {
  14092. $basePath = $path;
  14093. $removed = array();
  14094. while (!is_dir($basePath) && $basePath !== '\\') {
  14095. array_unshift($removed, basename($basePath));
  14096. $basePath = dirname($basePath);
  14097. }
  14098. if ($basePath === '\\') {
  14099. return $path;
  14100. }
  14101. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  14102. }
  14103. return $path;
  14104. }
  14105. protected function hasMetadataRepository($path)
  14106. {
  14107. $path = $this->normalizePath($path);
  14108. return is_dir($path.'/.git');
  14109. }
  14110. protected function getShortHash($reference)
  14111. {
  14112. if (!$this->io->isVerbose() && preg_match('{^[0-9a-f]{40}$}', $reference)) {
  14113. return substr($reference, 0, 10);
  14114. }
  14115. return $reference;
  14116. }
  14117. }
  14118. <?php
  14119. namespace Composer\Downloader;
  14120. use Composer\Package\PackageInterface;
  14121. use Composer\Util\Platform;
  14122. use Composer\Util\ProcessExecutor;
  14123. class GzipDownloader extends ArchiveDownloader
  14124. {
  14125. protected function extract(PackageInterface $package, $file, $path)
  14126. {
  14127. $filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
  14128. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  14129. if (!Platform::isWindows()) {
  14130. $command = 'gzip -cd -- ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  14131. if (0 === $this->process->execute($command, $ignoredOutput)) {
  14132. return \React\Promise\resolve();
  14133. }
  14134. if (extension_loaded('zlib')) {
  14135. $this->extractUsingExt($file, $targetFilepath);
  14136. return \React\Promise\resolve();
  14137. }
  14138. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  14139. throw new \RuntimeException($processError);
  14140. }
  14141. $this->extractUsingExt($file, $targetFilepath);
  14142. return \React\Promise\resolve();
  14143. }
  14144. private function extractUsingExt($file, $targetFilepath)
  14145. {
  14146. $archiveFile = gzopen($file, 'rb');
  14147. $targetFile = fopen($targetFilepath, 'wb');
  14148. while ($string = gzread($archiveFile, 4096)) {
  14149. fwrite($targetFile, $string, Platform::strlen($string));
  14150. }
  14151. gzclose($archiveFile);
  14152. fclose($targetFile);
  14153. }
  14154. }
  14155. <?php
  14156. namespace Composer\Downloader;
  14157. use Composer\Package\PackageInterface;
  14158. use Composer\Util\ProcessExecutor;
  14159. use Composer\Util\Hg as HgUtils;
  14160. class HgDownloader extends VcsDownloader
  14161. {
  14162. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  14163. {
  14164. if (null === HgUtils::getVersion($this->process)) {
  14165. throw new \RuntimeException('hg was not found in your PATH, skipping source download');
  14166. }
  14167. return \React\Promise\resolve();
  14168. }
  14169. protected function doInstall(PackageInterface $package, $path, $url)
  14170. {
  14171. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  14172. $cloneCommand = function ($url) use ($path) {
  14173. return sprintf('hg clone -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  14174. };
  14175. $hgUtils->runCommand($cloneCommand, $url, $path);
  14176. $ref = ProcessExecutor::escape($package->getSourceReference());
  14177. $command = sprintf('hg up -- %s', $ref);
  14178. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  14179. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14180. }
  14181. return \React\Promise\resolve();
  14182. }
  14183. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  14184. {
  14185. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  14186. $ref = $target->getSourceReference();
  14187. $this->io->writeError(" Updating to ".$target->getSourceReference());
  14188. if (!$this->hasMetadataRepository($path)) {
  14189. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  14190. }
  14191. $command = function ($url) use ($ref) {
  14192. return sprintf('hg pull -- %s && hg up -- %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  14193. };
  14194. $hgUtils->runCommand($command, $url, $path);
  14195. return \React\Promise\resolve();
  14196. }
  14197. public function getLocalChanges(PackageInterface $package, $path)
  14198. {
  14199. if (!is_dir($path.'/.hg')) {
  14200. return null;
  14201. }
  14202. $this->process->execute('hg st', $output, realpath($path));
  14203. return trim($output) ?: null;
  14204. }
  14205. protected function getCommitLogs($fromReference, $toReference, $path)
  14206. {
  14207. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  14208. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  14209. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14210. }
  14211. return $output;
  14212. }
  14213. protected function hasMetadataRepository($path)
  14214. {
  14215. return is_dir($path . '/.hg');
  14216. }
  14217. }
  14218. <?php
  14219. namespace Composer\Downloader;
  14220. class MaxFileSizeExceededException extends TransportException
  14221. {
  14222. }
  14223. <?php
  14224. namespace Composer\Downloader;
  14225. use Composer\Package\Archiver\ArchivableFilesFinder;
  14226. use Composer\Package\Dumper\ArrayDumper;
  14227. use Composer\Package\PackageInterface;
  14228. use Composer\Package\Version\VersionGuesser;
  14229. use Composer\Package\Version\VersionParser;
  14230. use Composer\Util\Platform;
  14231. use Composer\Util\Filesystem;
  14232. use Symfony\Component\Filesystem\Exception\IOException;
  14233. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  14234. use Composer\DependencyResolver\Operation\InstallOperation;
  14235. use Composer\DependencyResolver\Operation\UninstallOperation;
  14236. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  14237. {
  14238. const STRATEGY_SYMLINK = 10;
  14239. const STRATEGY_MIRROR = 20;
  14240. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  14241. {
  14242. $path = Filesystem::trimTrailingSlash($path);
  14243. $url = $package->getDistUrl();
  14244. $realUrl = realpath($url);
  14245. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  14246. throw new \RuntimeException(sprintf(
  14247. 'Source path "%s" is not found for package %s',
  14248. $url,
  14249. $package->getName()
  14250. ));
  14251. }
  14252. if (realpath($path) === $realUrl) {
  14253. return \React\Promise\resolve();
  14254. }
  14255. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  14256. throw new \RuntimeException(sprintf(
  14257. 'Package %s cannot install to "%s" inside its source at "%s"',
  14258. $package->getName(),
  14259. realpath($path),
  14260. $realUrl
  14261. ));
  14262. }
  14263. return \React\Promise\resolve();
  14264. }
  14265. public function install(PackageInterface $package, $path, $output = true)
  14266. {
  14267. $path = Filesystem::trimTrailingSlash($path);
  14268. $url = $package->getDistUrl();
  14269. $realUrl = realpath($url);
  14270. if (realpath($path) === $realUrl) {
  14271. if ($output) {
  14272. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  14273. }
  14274. return \React\Promise\resolve();
  14275. }
  14276. $transportOptions = $package->getTransportOptions() + array('relative' => true);
  14277. list($currentStrategy, $allowedStrategies) = $this->computeAllowedStrategies($transportOptions);
  14278. $symfonyFilesystem = new SymfonyFilesystem();
  14279. $this->filesystem->removeDirectory($path);
  14280. if ($output) {
  14281. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  14282. }
  14283. $isFallback = false;
  14284. if (self::STRATEGY_SYMLINK === $currentStrategy) {
  14285. try {
  14286. if (Platform::isWindows()) {
  14287. if ($output) {
  14288. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  14289. }
  14290. $this->filesystem->junction($realUrl, $path);
  14291. } else {
  14292. $absolutePath = $path;
  14293. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  14294. $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
  14295. }
  14296. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  14297. $path = rtrim($path, "/");
  14298. if ($output) {
  14299. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  14300. }
  14301. if ($transportOptions['relative']) {
  14302. $symfonyFilesystem->symlink($shortestPath, $path);
  14303. } else {
  14304. $symfonyFilesystem->symlink($realUrl, $path);
  14305. }
  14306. }
  14307. } catch (IOException $e) {
  14308. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
  14309. if ($output) {
  14310. $this->io->writeError('');
  14311. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  14312. }
  14313. $currentStrategy = self::STRATEGY_MIRROR;
  14314. $isFallback = true;
  14315. } else {
  14316. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  14317. }
  14318. }
  14319. }
  14320. if (self::STRATEGY_MIRROR === $currentStrategy) {
  14321. $realUrl = $this->filesystem->normalizePath($realUrl);
  14322. if ($output) {
  14323. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  14324. }
  14325. $iterator = new ArchivableFilesFinder($realUrl, array());
  14326. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  14327. }
  14328. if ($output) {
  14329. $this->io->writeError('');
  14330. }
  14331. return \React\Promise\resolve();
  14332. }
  14333. public function remove(PackageInterface $package, $path, $output = true)
  14334. {
  14335. $path = Filesystem::trimTrailingSlash($path);
  14336. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  14337. if ($output) {
  14338. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  14339. }
  14340. if (!$this->filesystem->removeJunction($path)) {
  14341. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  14342. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  14343. }
  14344. return \React\Promise\resolve();
  14345. }
  14346. $fs = new Filesystem;
  14347. $absPath = $fs->isAbsolutePath($path) ? $path : getcwd() . '/' . $path;
  14348. $absDistUrl = $fs->isAbsolutePath($package->getDistUrl()) ? $package->getDistUrl() : getcwd() . '/' . $package->getDistUrl();
  14349. if ($fs->normalizePath($absPath) === $fs->normalizePath($absDistUrl)) {
  14350. if ($output) {
  14351. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  14352. }
  14353. return \React\Promise\resolve();
  14354. }
  14355. return parent::remove($package, $path, $output);
  14356. }
  14357. public function getVcsReference(PackageInterface $package, $path)
  14358. {
  14359. $path = Filesystem::trimTrailingSlash($path);
  14360. $parser = new VersionParser;
  14361. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  14362. $dumper = new ArrayDumper;
  14363. $packageConfig = $dumper->dump($package);
  14364. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  14365. return $packageVersion['commit'];
  14366. }
  14367. return null;
  14368. }
  14369. protected function getInstallOperationAppendix(PackageInterface $package, $path)
  14370. {
  14371. $realUrl = realpath($package->getDistUrl());
  14372. if (realpath($path) === $realUrl) {
  14373. return ': Source already present';
  14374. }
  14375. list($currentStrategy) = $this->computeAllowedStrategies($package->getTransportOptions());
  14376. if ($currentStrategy === self::STRATEGY_SYMLINK) {
  14377. if (Platform::isWindows()) {
  14378. return ': Junctioning from '.$package->getDistUrl();
  14379. }
  14380. return ': Symlinking from '.$package->getDistUrl();
  14381. }
  14382. return ': Mirroring from '.$package->getDistUrl();
  14383. }
  14384. private function computeAllowedStrategies(array $transportOptions)
  14385. {
  14386. $currentStrategy = self::STRATEGY_SYMLINK;
  14387. $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
  14388. $mirrorPathRepos = getenv('COMPOSER_MIRROR_PATH_REPOS');
  14389. if ($mirrorPathRepos) {
  14390. $currentStrategy = self::STRATEGY_MIRROR;
  14391. }
  14392. $symlinkOption = isset($transportOptions['symlink']) ? $transportOptions['symlink'] : null;
  14393. if (true === $symlinkOption) {
  14394. $currentStrategy = self::STRATEGY_SYMLINK;
  14395. $allowedStrategies = array(self::STRATEGY_SYMLINK);
  14396. } elseif (false === $symlinkOption) {
  14397. $currentStrategy = self::STRATEGY_MIRROR;
  14398. $allowedStrategies = array(self::STRATEGY_MIRROR);
  14399. }
  14400. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  14401. $currentStrategy = self::STRATEGY_MIRROR;
  14402. $allowedStrategies = array(self::STRATEGY_MIRROR);
  14403. }
  14404. return array($currentStrategy, $allowedStrategies);
  14405. }
  14406. private function safeJunctions()
  14407. {
  14408. return function_exists('proc_open') &&
  14409. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  14410. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  14411. }
  14412. }
  14413. <?php
  14414. namespace Composer\Downloader;
  14415. use Composer\Package\PackageInterface;
  14416. use Composer\Repository\VcsRepository;
  14417. use Composer\Util\Perforce;
  14418. class PerforceDownloader extends VcsDownloader
  14419. {
  14420. protected $perforce;
  14421. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  14422. {
  14423. return \React\Promise\resolve();
  14424. }
  14425. public function doInstall(PackageInterface $package, $path, $url)
  14426. {
  14427. $ref = $package->getSourceReference();
  14428. $label = $this->getLabelFromSourceReference((string) $ref);
  14429. $this->io->writeError('Cloning ' . $ref);
  14430. $this->initPerforce($package, $path, $url);
  14431. $this->perforce->setStream($ref);
  14432. $this->perforce->p4Login();
  14433. $this->perforce->writeP4ClientSpec();
  14434. $this->perforce->connectClient();
  14435. $this->perforce->syncCodeBase($label);
  14436. $this->perforce->cleanupClientSpec();
  14437. return \React\Promise\resolve();
  14438. }
  14439. private function getLabelFromSourceReference($ref)
  14440. {
  14441. $pos = strpos($ref, '@');
  14442. if (false !== $pos) {
  14443. return substr($ref, $pos + 1);
  14444. }
  14445. return null;
  14446. }
  14447. public function initPerforce(PackageInterface $package, $path, $url)
  14448. {
  14449. if (!empty($this->perforce)) {
  14450. $this->perforce->initializePath($path);
  14451. return;
  14452. }
  14453. $repository = $package->getRepository();
  14454. $repoConfig = null;
  14455. if ($repository instanceof VcsRepository) {
  14456. $repoConfig = $this->getRepoConfig($repository);
  14457. }
  14458. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  14459. }
  14460. private function getRepoConfig(VcsRepository $repository)
  14461. {
  14462. return $repository->getRepoConfig();
  14463. }
  14464. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  14465. {
  14466. return $this->doInstall($target, $path, $url);
  14467. }
  14468. public function getLocalChanges(PackageInterface $package, $path)
  14469. {
  14470. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  14471. return null;
  14472. }
  14473. protected function getCommitLogs($fromReference, $toReference, $path)
  14474. {
  14475. return $this->perforce->getCommitLogs($fromReference, $toReference);
  14476. }
  14477. public function setPerforce(Perforce $perforce)
  14478. {
  14479. $this->perforce = $perforce;
  14480. }
  14481. protected function hasMetadataRepository($path)
  14482. {
  14483. return true;
  14484. }
  14485. }
  14486. <?php
  14487. namespace Composer\Downloader;
  14488. use Composer\Package\PackageInterface;
  14489. class PharDownloader extends ArchiveDownloader
  14490. {
  14491. protected function extract(PackageInterface $package, $file, $path)
  14492. {
  14493. $archive = new \Phar($file);
  14494. $archive->extractTo($path, null, true);
  14495. return \React\Promise\resolve();
  14496. }
  14497. }
  14498. <?php
  14499. namespace Composer\Downloader;
  14500. use Composer\Util\IniHelper;
  14501. use Composer\Util\Platform;
  14502. use Composer\Util\ProcessExecutor;
  14503. use Composer\Package\PackageInterface;
  14504. use RarArchive;
  14505. class RarDownloader extends ArchiveDownloader
  14506. {
  14507. protected function extract(PackageInterface $package, $file, $path)
  14508. {
  14509. $processError = null;
  14510. if (!Platform::isWindows()) {
  14511. $command = 'unrar x -- ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  14512. if (0 === $this->process->execute($command, $ignoredOutput)) {
  14513. return \React\Promise\resolve();
  14514. }
  14515. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  14516. }
  14517. if (!class_exists('RarArchive')) {
  14518. $iniMessage = IniHelper::getMessage();
  14519. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  14520. . $iniMessage . "\n" . $processError;
  14521. if (!Platform::isWindows()) {
  14522. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  14523. }
  14524. throw new \RuntimeException($error);
  14525. }
  14526. $rarArchive = RarArchive::open($file);
  14527. if (false === $rarArchive) {
  14528. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  14529. }
  14530. $entries = $rarArchive->getEntries();
  14531. if (false === $entries) {
  14532. throw new \RuntimeException('Could not retrieve RAR archive entries');
  14533. }
  14534. foreach ($entries as $entry) {
  14535. if (false === $entry->extract($path)) {
  14536. throw new \RuntimeException('Could not extract entry');
  14537. }
  14538. }
  14539. $rarArchive->close();
  14540. return \React\Promise\resolve();
  14541. }
  14542. }
  14543. <?php
  14544. namespace Composer\Downloader;
  14545. use Composer\Package\PackageInterface;
  14546. use Composer\Util\Svn as SvnUtil;
  14547. use Composer\Repository\VcsRepository;
  14548. use Composer\Util\ProcessExecutor;
  14549. use React\Promise\PromiseInterface;
  14550. class SvnDownloader extends VcsDownloader
  14551. {
  14552. protected $cacheCredentials = true;
  14553. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  14554. {
  14555. SvnUtil::cleanEnv();
  14556. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  14557. if (null === $util->binaryVersion()) {
  14558. throw new \RuntimeException('svn was not found in your PATH, skipping source download');
  14559. }
  14560. return \React\Promise\resolve();
  14561. }
  14562. protected function doInstall(PackageInterface $package, $path, $url)
  14563. {
  14564. SvnUtil::cleanEnv();
  14565. $ref = $package->getSourceReference();
  14566. $repo = $package->getRepository();
  14567. if ($repo instanceof VcsRepository) {
  14568. $repoConfig = $repo->getRepoConfig();
  14569. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  14570. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  14571. }
  14572. }
  14573. $this->io->writeError(" Checking out ".$package->getSourceReference());
  14574. $this->execute($package, $url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  14575. return \React\Promise\resolve();
  14576. }
  14577. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  14578. {
  14579. SvnUtil::cleanEnv();
  14580. $ref = $target->getSourceReference();
  14581. if (!$this->hasMetadataRepository($path)) {
  14582. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  14583. }
  14584. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  14585. $flags = "";
  14586. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  14587. $flags .= ' --ignore-ancestry';
  14588. }
  14589. $this->io->writeError(" Checking out " . $ref);
  14590. $this->execute($target, $url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  14591. return \React\Promise\resolve();
  14592. }
  14593. public function getLocalChanges(PackageInterface $package, $path)
  14594. {
  14595. if (!$this->hasMetadataRepository($path)) {
  14596. return null;
  14597. }
  14598. $this->process->execute('svn status --ignore-externals', $output, $path);
  14599. return preg_match('{^ *[^X ] +}m', $output) ? $output : null;
  14600. }
  14601. protected function execute(PackageInterface $package, $baseUrl, $command, $url, $cwd = null, $path = null)
  14602. {
  14603. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  14604. $util->setCacheCredentials($this->cacheCredentials);
  14605. try {
  14606. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  14607. } catch (\RuntimeException $e) {
  14608. throw new \RuntimeException(
  14609. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  14610. );
  14611. }
  14612. }
  14613. protected function cleanChanges(PackageInterface $package, $path, $update)
  14614. {
  14615. if (!$changes = $this->getLocalChanges($package, $path)) {
  14616. return \React\Promise\resolve();
  14617. }
  14618. if (!$this->io->isInteractive()) {
  14619. if (true === $this->config->get('discard-changes')) {
  14620. return $this->discardChanges($path);
  14621. }
  14622. return parent::cleanChanges($package, $path, $update);
  14623. }
  14624. $changes = array_map(function ($elem) {
  14625. return ' '.$elem;
  14626. }, preg_split('{\s*\r?\n\s*}', $changes));
  14627. $countChanges = count($changes);
  14628. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  14629. $this->io->writeError(array_slice($changes, 0, 10));
  14630. if ($countChanges > 10) {
  14631. $remainingChanges = $countChanges - 10;
  14632. $this->io->writeError(
  14633. sprintf(
  14634. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  14635. $remainingChanges === 1 ? '' : 's'
  14636. )
  14637. );
  14638. }
  14639. while (true) {
  14640. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  14641. case 'y':
  14642. $this->discardChanges($path);
  14643. break 2;
  14644. case 'n':
  14645. throw new \RuntimeException('Update aborted');
  14646. case 'v':
  14647. $this->io->writeError($changes);
  14648. break;
  14649. case '?':
  14650. default:
  14651. $this->io->writeError(array(
  14652. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  14653. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  14654. ' v - view modified files',
  14655. ' ? - print help',
  14656. ));
  14657. break;
  14658. }
  14659. }
  14660. return \React\Promise\resolve();
  14661. }
  14662. protected function getCommitLogs($fromReference, $toReference, $path)
  14663. {
  14664. if (preg_match('{@(\d+)$}', $fromReference) && preg_match('{@(\d+)$}', $toReference)) {
  14665. $command = sprintf('svn info --non-interactive --xml -- %s', ProcessExecutor::escape($path));
  14666. if (0 !== $this->process->execute($command, $output, $path)) {
  14667. throw new \RuntimeException(
  14668. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  14669. );
  14670. }
  14671. $urlPattern = '#<url>(.*)</url>#';
  14672. if (preg_match($urlPattern, $output, $matches)) {
  14673. $baseUrl = $matches[1];
  14674. } else {
  14675. throw new \RuntimeException(
  14676. 'Unable to determine svn url for path '. $path
  14677. );
  14678. }
  14679. $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference);
  14680. $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference);
  14681. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  14682. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  14683. $util->setCacheCredentials($this->cacheCredentials);
  14684. try {
  14685. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  14686. } catch (\RuntimeException $e) {
  14687. throw new \RuntimeException(
  14688. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  14689. );
  14690. }
  14691. }
  14692. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  14693. }
  14694. protected function discardChanges($path)
  14695. {
  14696. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  14697. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  14698. }
  14699. return \React\Promise\resolve();
  14700. }
  14701. protected function hasMetadataRepository($path)
  14702. {
  14703. return is_dir($path.'/.svn');
  14704. }
  14705. }
  14706. <?php
  14707. namespace Composer\Downloader;
  14708. use Composer\Package\PackageInterface;
  14709. class TarDownloader extends ArchiveDownloader
  14710. {
  14711. protected function extract(PackageInterface $package, $file, $path)
  14712. {
  14713. $archive = new \PharData($file);
  14714. $archive->extractTo($path, null, true);
  14715. return \React\Promise\resolve();
  14716. }
  14717. }
  14718. <?php
  14719. namespace Composer\Downloader;
  14720. class TransportException extends \RuntimeException
  14721. {
  14722. protected $headers;
  14723. protected $response;
  14724. protected $statusCode;
  14725. protected $responseInfo = array();
  14726. public function setHeaders($headers)
  14727. {
  14728. $this->headers = $headers;
  14729. }
  14730. public function getHeaders()
  14731. {
  14732. return $this->headers;
  14733. }
  14734. public function setResponse($response)
  14735. {
  14736. $this->response = $response;
  14737. }
  14738. public function getResponse()
  14739. {
  14740. return $this->response;
  14741. }
  14742. public function setStatusCode($statusCode)
  14743. {
  14744. $this->statusCode = $statusCode;
  14745. }
  14746. public function getStatusCode()
  14747. {
  14748. return $this->statusCode;
  14749. }
  14750. public function getResponseInfo()
  14751. {
  14752. return $this->responseInfo;
  14753. }
  14754. public function setResponseInfo(array $responseInfo)
  14755. {
  14756. $this->responseInfo = $responseInfo;
  14757. }
  14758. }
  14759. <?php
  14760. namespace Composer\Downloader;
  14761. use Composer\Package\PackageInterface;
  14762. interface VcsCapableDownloaderInterface
  14763. {
  14764. public function getVcsReference(PackageInterface $package, $path);
  14765. }
  14766. <?php
  14767. namespace Composer\Downloader;
  14768. use Composer\Config;
  14769. use Composer\Package\Dumper\ArrayDumper;
  14770. use Composer\Package\PackageInterface;
  14771. use Composer\Package\Version\VersionGuesser;
  14772. use Composer\Package\Version\VersionParser;
  14773. use Composer\Util\ProcessExecutor;
  14774. use Composer\IO\IOInterface;
  14775. use Composer\Util\Filesystem;
  14776. use React\Promise\PromiseInterface;
  14777. use Composer\DependencyResolver\Operation\UpdateOperation;
  14778. use Composer\DependencyResolver\Operation\InstallOperation;
  14779. use Composer\DependencyResolver\Operation\UninstallOperation;
  14780. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  14781. {
  14782. protected $io;
  14783. protected $config;
  14784. protected $process;
  14785. protected $filesystem;
  14786. protected $hasCleanedChanges = array();
  14787. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  14788. {
  14789. $this->io = $io;
  14790. $this->config = $config;
  14791. $this->process = $process ?: new ProcessExecutor($io);
  14792. $this->filesystem = $fs ?: new Filesystem($this->process);
  14793. }
  14794. public function getInstallationSource()
  14795. {
  14796. return 'source';
  14797. }
  14798. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null)
  14799. {
  14800. if (!$package->getSourceReference()) {
  14801. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  14802. }
  14803. $urls = $this->prepareUrls($package->getSourceUrls());
  14804. while ($url = array_shift($urls)) {
  14805. try {
  14806. return $this->doDownload($package, $path, $url, $prevPackage);
  14807. } catch (\Exception $e) {
  14808. if ($e instanceof \PHPUnit\Framework\Exception) {
  14809. throw $e;
  14810. }
  14811. if ($this->io->isDebug()) {
  14812. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  14813. } elseif (count($urls)) {
  14814. $this->io->writeError(' Failed, trying the next URL');
  14815. }
  14816. if (!count($urls)) {
  14817. throw $e;
  14818. }
  14819. }
  14820. }
  14821. return \React\Promise\resolve();
  14822. }
  14823. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  14824. {
  14825. if ($type === 'update') {
  14826. $this->cleanChanges($prevPackage, $path, true);
  14827. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  14828. } elseif ($type === 'install') {
  14829. $this->filesystem->emptyDirectory($path);
  14830. } elseif ($type === 'uninstall') {
  14831. $this->cleanChanges($package, $path, false);
  14832. }
  14833. return \React\Promise\resolve();
  14834. }
  14835. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  14836. {
  14837. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  14838. $this->reapplyChanges($path);
  14839. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  14840. }
  14841. return \React\Promise\resolve();
  14842. }
  14843. public function install(PackageInterface $package, $path)
  14844. {
  14845. if (!$package->getSourceReference()) {
  14846. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  14847. }
  14848. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  14849. $urls = $this->prepareUrls($package->getSourceUrls());
  14850. while ($url = array_shift($urls)) {
  14851. try {
  14852. $this->doInstall($package, $path, $url);
  14853. break;
  14854. } catch (\Exception $e) {
  14855. if ($e instanceof \PHPUnit\Framework\Exception) {
  14856. throw $e;
  14857. }
  14858. if ($this->io->isDebug()) {
  14859. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  14860. } elseif (count($urls)) {
  14861. $this->io->writeError(' Failed, trying the next URL');
  14862. }
  14863. if (!count($urls)) {
  14864. throw $e;
  14865. }
  14866. }
  14867. }
  14868. return \React\Promise\resolve();
  14869. }
  14870. public function update(PackageInterface $initial, PackageInterface $target, $path)
  14871. {
  14872. if (!$target->getSourceReference()) {
  14873. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  14874. }
  14875. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  14876. $urls = $this->prepareUrls($target->getSourceUrls());
  14877. $exception = null;
  14878. while ($url = array_shift($urls)) {
  14879. try {
  14880. $this->doUpdate($initial, $target, $path, $url);
  14881. $exception = null;
  14882. break;
  14883. } catch (\Exception $exception) {
  14884. if ($exception instanceof \PHPUnit\Framework\Exception) {
  14885. throw $exception;
  14886. }
  14887. if ($this->io->isDebug()) {
  14888. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  14889. } elseif (count($urls)) {
  14890. $this->io->writeError(' Failed, trying the next URL');
  14891. }
  14892. }
  14893. }
  14894. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  14895. $message = 'Pulling in changes:';
  14896. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  14897. if (!trim($logs)) {
  14898. $message = 'Rolling back changes:';
  14899. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  14900. }
  14901. if (trim($logs)) {
  14902. $logs = implode("\n", array_map(function ($line) {
  14903. return ' ' . $line;
  14904. }, explode("\n", $logs)));
  14905. $logs = str_replace('<', '\<', $logs);
  14906. $this->io->writeError(' '.$message);
  14907. $this->io->writeError($logs);
  14908. }
  14909. }
  14910. if (!$urls && $exception) {
  14911. throw $exception;
  14912. }
  14913. return \React\Promise\resolve();
  14914. }
  14915. public function remove(PackageInterface $package, $path)
  14916. {
  14917. $this->io->writeError(" - " . UninstallOperation::format($package));
  14918. $promise = $this->filesystem->removeDirectoryAsync($path);
  14919. return $promise->then(function ($result) use ($path) {
  14920. if (!$result) {
  14921. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  14922. }
  14923. });
  14924. }
  14925. public function getVcsReference(PackageInterface $package, $path)
  14926. {
  14927. $parser = new VersionParser;
  14928. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  14929. $dumper = new ArrayDumper;
  14930. $packageConfig = $dumper->dump($package);
  14931. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  14932. return $packageVersion['commit'];
  14933. }
  14934. return null;
  14935. }
  14936. protected function cleanChanges(PackageInterface $package, $path, $update)
  14937. {
  14938. if (null !== $this->getLocalChanges($package, $path)) {
  14939. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  14940. }
  14941. return \React\Promise\resolve();
  14942. }
  14943. protected function reapplyChanges($path)
  14944. {
  14945. }
  14946. abstract protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null);
  14947. abstract protected function doInstall(PackageInterface $package, $path, $url);
  14948. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url);
  14949. abstract protected function getCommitLogs($fromReference, $toReference, $path);
  14950. abstract protected function hasMetadataRepository($path);
  14951. private function prepareUrls(array $urls)
  14952. {
  14953. foreach ($urls as $index => $url) {
  14954. if (Filesystem::isLocalPath($url)) {
  14955. $fileProtocol = 'file://';
  14956. $isFileProtocol = false;
  14957. if (0 === strpos($url, $fileProtocol)) {
  14958. $url = substr($url, strlen($fileProtocol));
  14959. $isFileProtocol = true;
  14960. }
  14961. if (false !== strpos($url, '%')) {
  14962. $url = rawurldecode($url);
  14963. }
  14964. $urls[$index] = realpath($url);
  14965. if ($isFileProtocol) {
  14966. $urls[$index] = $fileProtocol . $urls[$index];
  14967. }
  14968. }
  14969. }
  14970. return $urls;
  14971. }
  14972. }
  14973. <?php
  14974. namespace Composer\Downloader;
  14975. use Composer\Package\PackageInterface;
  14976. use Composer\Util\ProcessExecutor;
  14977. class XzDownloader extends ArchiveDownloader
  14978. {
  14979. protected function extract(PackageInterface $package, $file, $path)
  14980. {
  14981. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  14982. if (0 === $this->process->execute($command, $ignoredOutput)) {
  14983. return \React\Promise\resolve();
  14984. }
  14985. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  14986. throw new \RuntimeException($processError);
  14987. }
  14988. }
  14989. <?php
  14990. namespace Composer\Downloader;
  14991. use Composer\Package\PackageInterface;
  14992. use Composer\Util\IniHelper;
  14993. use Composer\Util\Platform;
  14994. use Composer\Util\ProcessExecutor;
  14995. use Symfony\Component\Process\ExecutableFinder;
  14996. use React\Promise\PromiseInterface;
  14997. use ZipArchive;
  14998. class ZipDownloader extends ArchiveDownloader
  14999. {
  15000. private static $unzipCommands;
  15001. private static $hasZipArchive;
  15002. private static $isWindows;
  15003. private $zipArchiveObject;
  15004. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  15005. {
  15006. if (null === self::$unzipCommands) {
  15007. self::$unzipCommands = array();
  15008. $finder = new ExecutableFinder;
  15009. if (Platform::isWindows() && ($cmd = $finder->find('7z', null, array('C:\Program Files\7-Zip')))) {
  15010. self::$unzipCommands[] = array('7z', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
  15011. }
  15012. if ($cmd = $finder->find('unzip')) {
  15013. self::$unzipCommands[] = array('unzip', ProcessExecutor::escape($cmd).' -qq %s -d %s');
  15014. }
  15015. if (!Platform::isWindows() && ($cmd = $finder->find('7z'))) {
  15016. self::$unzipCommands[] = array('7z', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
  15017. }
  15018. if (!Platform::isWindows() && ($cmd = $finder->find('7zz'))) {
  15019. self::$unzipCommands[] = array('7zz', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
  15020. }
  15021. }
  15022. $procOpenMissing = false;
  15023. if (!function_exists('proc_open')) {
  15024. self::$unzipCommands = array();
  15025. $procOpenMissing = true;
  15026. }
  15027. if (null === self::$hasZipArchive) {
  15028. self::$hasZipArchive = class_exists('ZipArchive');
  15029. }
  15030. if (!self::$hasZipArchive && !self::$unzipCommands) {
  15031. $iniMessage = IniHelper::getMessage();
  15032. if ($procOpenMissing) {
  15033. $error = "The zip extension is missing and unzip/7z commands cannot be called as proc_open is disabled, skipping.\n" . $iniMessage;
  15034. } else {
  15035. $error = "The zip extension and unzip/7z commands are both missing, skipping.\n" . $iniMessage;
  15036. }
  15037. throw new \RuntimeException($error);
  15038. }
  15039. if (null === self::$isWindows) {
  15040. self::$isWindows = Platform::isWindows();
  15041. if (!self::$isWindows && !self::$unzipCommands) {
  15042. if ($procOpenMissing) {
  15043. $this->io->writeError("<warning>proc_open is disabled so 'unzip' and '7z' commands cannot be used, zip files are being unpacked using the PHP zip extension.</warning>");
  15044. $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>");
  15045. $this->io->writeError("<warning>Enabling proc_open and installing 'unzip' or '7z' may remediate them.</warning>");
  15046. } else {
  15047. $this->io->writeError("<warning>As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  15048. $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>");
  15049. $this->io->writeError("<warning>Installing 'unzip' or '7z' may remediate them.</warning>");
  15050. }
  15051. }
  15052. }
  15053. return parent::download($package, $path, $prevPackage, $output);
  15054. }
  15055. private function extractWithSystemUnzip(PackageInterface $package, $file, $path)
  15056. {
  15057. $isLastChance = !self::$hasZipArchive;
  15058. if (!self::$unzipCommands) {
  15059. return $this->extractWithZipArchive($package, $file, $path);
  15060. }
  15061. $commandSpec = reset(self::$unzipCommands);
  15062. $command = sprintf($commandSpec[1], ProcessExecutor::escape($file), ProcessExecutor::escape($path));
  15063. if (Platform::isWindows()) {
  15064. $command = sprintf($commandSpec[1], ProcessExecutor::escape(strtr($file, '/', '\\')), ProcessExecutor::escape(strtr($path, '/', '\\')));
  15065. }
  15066. $executable = $commandSpec[0];
  15067. $self = $this;
  15068. $io = $this->io;
  15069. $tryFallback = function ($processError) use ($isLastChance, $io, $self, $file, $path, $package, $executable) {
  15070. if ($isLastChance) {
  15071. throw $processError;
  15072. }
  15073. if (!is_file($file)) {
  15074. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  15075. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  15076. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  15077. } else {
  15078. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  15079. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  15080. $io->writeError(' Unzip with '.$executable.' command failed, falling back to ZipArchive class');
  15081. }
  15082. return $self->extractWithZipArchive($package, $file, $path);
  15083. };
  15084. try {
  15085. $promise = $this->process->executeAsync($command);
  15086. return $promise->then(function ($process) use ($tryFallback, $command, $package, $file, $self) {
  15087. if (!$process->isSuccessful()) {
  15088. if (isset($self->cleanupExecuted[$package->getName()])) {
  15089. throw new \RuntimeException('Failed to extract '.$package->getName().' as the installation was aborted by another package operation.');
  15090. }
  15091. $output = $process->getErrorOutput();
  15092. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  15093. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
  15094. }
  15095. });
  15096. } catch (\Exception $e) {
  15097. return $tryFallback($e);
  15098. } catch (\Throwable $e) {
  15099. return $tryFallback($e);
  15100. }
  15101. }
  15102. public function extractWithZipArchive(PackageInterface $package, $file, $path)
  15103. {
  15104. $processError = null;
  15105. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  15106. try {
  15107. if (true === ($retval = $zipArchive->open($file))) {
  15108. $extractResult = $zipArchive->extractTo($path);
  15109. if (true === $extractResult) {
  15110. $zipArchive->close();
  15111. return \React\Promise\resolve();
  15112. }
  15113. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  15114. } else {
  15115. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  15116. }
  15117. } catch (\ErrorException $e) {
  15118. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  15119. } catch (\Exception $e) {
  15120. $processError = $e;
  15121. } catch (\Throwable $e) {
  15122. $processError = $e;
  15123. }
  15124. throw $processError;
  15125. }
  15126. public function extract(PackageInterface $package, $file, $path)
  15127. {
  15128. return $this->extractWithSystemUnzip($package, $file, $path);
  15129. }
  15130. protected function getErrorMessage($retval, $file)
  15131. {
  15132. switch ($retval) {
  15133. case ZipArchive::ER_EXISTS:
  15134. return sprintf("File '%s' already exists.", $file);
  15135. case ZipArchive::ER_INCONS:
  15136. return sprintf("Zip archive '%s' is inconsistent.", $file);
  15137. case ZipArchive::ER_INVAL:
  15138. return sprintf("Invalid argument (%s)", $file);
  15139. case ZipArchive::ER_MEMORY:
  15140. return sprintf("Malloc failure (%s)", $file);
  15141. case ZipArchive::ER_NOENT:
  15142. return sprintf("No such zip file: '%s'", $file);
  15143. case ZipArchive::ER_NOZIP:
  15144. return sprintf("'%s' is not a zip archive.", $file);
  15145. case ZipArchive::ER_OPEN:
  15146. return sprintf("Can't open zip file: %s", $file);
  15147. case ZipArchive::ER_READ:
  15148. return sprintf("Zip read error (%s)", $file);
  15149. case ZipArchive::ER_SEEK:
  15150. return sprintf("Zip seek error (%s)", $file);
  15151. default:
  15152. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  15153. }
  15154. }
  15155. }
  15156. <?php
  15157. namespace Composer\EventDispatcher;
  15158. class Event
  15159. {
  15160. protected $name;
  15161. protected $args;
  15162. protected $flags;
  15163. private $propagationStopped = false;
  15164. public function __construct($name, array $args = array(), array $flags = array())
  15165. {
  15166. $this->name = $name;
  15167. $this->args = $args;
  15168. $this->flags = $flags;
  15169. }
  15170. public function getName()
  15171. {
  15172. return $this->name;
  15173. }
  15174. public function getArguments()
  15175. {
  15176. return $this->args;
  15177. }
  15178. public function getFlags()
  15179. {
  15180. return $this->flags;
  15181. }
  15182. public function isPropagationStopped()
  15183. {
  15184. return $this->propagationStopped;
  15185. }
  15186. public function stopPropagation()
  15187. {
  15188. $this->propagationStopped = true;
  15189. }
  15190. }
  15191. <?php
  15192. namespace Composer\EventDispatcher;
  15193. use Composer\DependencyResolver\Transaction;
  15194. use Composer\Installer\InstallerEvent;
  15195. use Composer\IO\IOInterface;
  15196. use Composer\Composer;
  15197. use Composer\Util\Platform;
  15198. use Composer\DependencyResolver\Operation\OperationInterface;
  15199. use Composer\Repository\RepositoryInterface;
  15200. use Composer\Script;
  15201. use Composer\Installer\PackageEvent;
  15202. use Composer\Installer\BinaryInstaller;
  15203. use Composer\Util\ProcessExecutor;
  15204. use Composer\Script\Event as ScriptEvent;
  15205. use Composer\Autoload\ClassLoader;
  15206. use Symfony\Component\Process\PhpExecutableFinder;
  15207. use Symfony\Component\Process\ExecutableFinder;
  15208. class EventDispatcher
  15209. {
  15210. protected $composer;
  15211. protected $io;
  15212. protected $loader;
  15213. protected $process;
  15214. protected $listeners = array();
  15215. protected $runScripts = true;
  15216. private $eventStack;
  15217. public function __construct(Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  15218. {
  15219. $this->composer = $composer;
  15220. $this->io = $io;
  15221. $this->process = $process ?: new ProcessExecutor($io);
  15222. $this->eventStack = array();
  15223. }
  15224. public function setRunScripts($runScripts = true)
  15225. {
  15226. $this->runScripts = (bool) $runScripts;
  15227. return $this;
  15228. }
  15229. public function dispatch($eventName, Event $event = null)
  15230. {
  15231. if (null === $event) {
  15232. $event = new Event($eventName);
  15233. }
  15234. return $this->doDispatch($event);
  15235. }
  15236. public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
  15237. {
  15238. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  15239. }
  15240. public function dispatchPackageEvent($eventName, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  15241. {
  15242. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  15243. }
  15244. public function dispatchInstallerEvent($eventName, $devMode, $executeOperations, Transaction $transaction)
  15245. {
  15246. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  15247. }
  15248. protected function doDispatch(Event $event)
  15249. {
  15250. if (getenv('COMPOSER_DEBUG_EVENTS')) {
  15251. $details = null;
  15252. if ($event instanceof PackageEvent) {
  15253. $details = (string) $event->getOperation();
  15254. }
  15255. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  15256. }
  15257. $listeners = $this->getListeners($event);
  15258. $this->pushEvent($event);
  15259. try {
  15260. $returnMax = 0;
  15261. foreach ($listeners as $callable) {
  15262. $return = 0;
  15263. $this->ensureBinDirIsInPath();
  15264. if (!is_string($callable)) {
  15265. if (!is_callable($callable)) {
  15266. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  15267. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  15268. }
  15269. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  15270. $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1]), true, IOInterface::VERBOSE);
  15271. }
  15272. $return = false === call_user_func($callable, $event) ? 1 : 0;
  15273. } elseif ($this->isComposerScript($callable)) {
  15274. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  15275. $script = explode(' ', substr($callable, 1));
  15276. $scriptName = $script[0];
  15277. unset($script[0]);
  15278. $args = array_merge($script, $event->getArguments());
  15279. $flags = $event->getFlags();
  15280. if (strpos($callable, '@composer ') === 0) {
  15281. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  15282. if (0 !== ($exitCode = $this->executeTty($exec))) {
  15283. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  15284. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  15285. }
  15286. } else {
  15287. if (!$this->getListeners(new Event($scriptName))) {
  15288. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  15289. }
  15290. try {
  15291. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  15292. $scriptEvent->setOriginatingEvent($event);
  15293. $return = $this->dispatch($scriptName, $scriptEvent);
  15294. } catch (ScriptExecutionException $e) {
  15295. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  15296. throw $e;
  15297. }
  15298. }
  15299. } elseif ($this->isPhpScript($callable)) {
  15300. $className = substr($callable, 0, strpos($callable, '::'));
  15301. $methodName = substr($callable, strpos($callable, '::') + 2);
  15302. if (!class_exists($className)) {
  15303. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  15304. continue;
  15305. }
  15306. if (!is_callable($callable)) {
  15307. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  15308. continue;
  15309. }
  15310. try {
  15311. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  15312. } catch (\Exception $e) {
  15313. $message = "Script %s handling the %s event terminated with an exception";
  15314. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  15315. throw $e;
  15316. }
  15317. } else {
  15318. $args = implode(' ', array_map(array('Composer\Util\ProcessExecutor', 'escape'), $event->getArguments()));
  15319. $exec = $callable . ($args === '' ? '' : ' '.$args);
  15320. if ($this->io->isVerbose()) {
  15321. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  15322. } elseif ($event->getName() !== '__exec_command') {
  15323. $this->io->writeError(sprintf('> %s', $exec));
  15324. }
  15325. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  15326. if ($possibleLocalBinaries) {
  15327. foreach ($possibleLocalBinaries as $localExec) {
  15328. if (preg_match('{\b'.preg_quote($callable).'$}', $localExec)) {
  15329. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  15330. $exec = preg_replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  15331. break;
  15332. }
  15333. }
  15334. }
  15335. if (strpos($exec, '@putenv ') === 0) {
  15336. if (false === strpos($exec, '=')) {
  15337. Platform::clearEnv(substr($exec, 8));
  15338. } else {
  15339. list($var, $value) = explode('=', substr($exec, 8), 2);
  15340. Platform::putEnv($var, $value);
  15341. }
  15342. continue;
  15343. }
  15344. if (strpos($exec, '@php ') === 0) {
  15345. $pathAndArgs = substr($exec, 5);
  15346. if (Platform::isWindows()) {
  15347. $pathAndArgs = preg_replace_callback('{^\S+}', function ($path) {
  15348. return str_replace('/', '\\', $path[0]);
  15349. }, $pathAndArgs);
  15350. }
  15351. $matched = preg_match('{^[^\'"\s/\\\\]+}', $pathAndArgs, $match);
  15352. if ($matched && !file_exists($match[0])) {
  15353. $finder = new ExecutableFinder;
  15354. if ($pathToExec = $finder->find($match[0])) {
  15355. $pathAndArgs = $pathToExec . substr($pathAndArgs, strlen($match[0]));
  15356. }
  15357. }
  15358. $exec = $this->getPhpExecCommand() . ' ' . $pathAndArgs;
  15359. } else {
  15360. $finder = new PhpExecutableFinder();
  15361. $phpPath = $finder->find(false);
  15362. if ($phpPath) {
  15363. Platform::putEnv('PHP_BINARY', $phpPath);
  15364. }
  15365. if (Platform::isWindows()) {
  15366. $exec = preg_replace_callback('{^\S+}', function ($path) {
  15367. return str_replace('/', '\\', $path[0]);
  15368. }, $exec);
  15369. }
  15370. }
  15371. if (strpos($exec, 'composer ') === 0) {
  15372. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($exec, 8);
  15373. }
  15374. if (0 !== ($exitCode = $this->executeTty($exec))) {
  15375. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  15376. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  15377. }
  15378. }
  15379. $returnMax = max($returnMax, $return);
  15380. if ($event->isPropagationStopped()) {
  15381. break;
  15382. }
  15383. }
  15384. } catch (\Exception $e) {
  15385. $this->popEvent();
  15386. throw $e;
  15387. } catch (\Throwable $e) {
  15388. $this->popEvent();
  15389. throw $e;
  15390. }
  15391. $this->popEvent();
  15392. return $returnMax;
  15393. }
  15394. protected function executeTty($exec)
  15395. {
  15396. if ($this->io->isInteractive()) {
  15397. return $this->process->executeTty($exec);
  15398. }
  15399. return $this->process->execute($exec);
  15400. }
  15401. protected function getPhpExecCommand()
  15402. {
  15403. $finder = new PhpExecutableFinder();
  15404. $phpPath = $finder->find(false);
  15405. if (!$phpPath) {
  15406. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  15407. }
  15408. $phpArgs = $finder->findArguments();
  15409. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  15410. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  15411. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  15412. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  15413. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  15414. }
  15415. protected function executeEventPhpScript($className, $methodName, Event $event)
  15416. {
  15417. if ($this->io->isVerbose()) {
  15418. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  15419. } else {
  15420. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  15421. }
  15422. return $className::$methodName($event);
  15423. }
  15424. public function addListener($eventName, $listener, $priority = 0)
  15425. {
  15426. $this->listeners[$eventName][$priority][] = $listener;
  15427. }
  15428. public function removeListener($listener)
  15429. {
  15430. foreach ($this->listeners as $eventName => $priorities) {
  15431. foreach ($priorities as $priority => $listeners) {
  15432. foreach ($listeners as $index => $candidate) {
  15433. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  15434. unset($this->listeners[$eventName][$priority][$index]);
  15435. }
  15436. }
  15437. }
  15438. }
  15439. }
  15440. public function addSubscriber(EventSubscriberInterface $subscriber)
  15441. {
  15442. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  15443. if (is_string($params)) {
  15444. $this->addListener($eventName, array($subscriber, $params));
  15445. } elseif (is_string($params[0])) {
  15446. $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
  15447. } else {
  15448. foreach ($params as $listener) {
  15449. $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
  15450. }
  15451. }
  15452. }
  15453. }
  15454. protected function getListeners(Event $event)
  15455. {
  15456. $scriptListeners = $this->runScripts ? $this->getScriptListeners($event) : array();
  15457. if (!isset($this->listeners[$event->getName()][0])) {
  15458. $this->listeners[$event->getName()][0] = array();
  15459. }
  15460. krsort($this->listeners[$event->getName()]);
  15461. $listeners = $this->listeners;
  15462. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  15463. return call_user_func_array('array_merge', $listeners[$event->getName()]);
  15464. }
  15465. public function hasEventListeners(Event $event)
  15466. {
  15467. $listeners = $this->getListeners($event);
  15468. return count($listeners) > 0;
  15469. }
  15470. protected function getScriptListeners(Event $event)
  15471. {
  15472. $package = $this->composer->getPackage();
  15473. $scripts = $package->getScripts();
  15474. if (empty($scripts[$event->getName()])) {
  15475. return array();
  15476. }
  15477. if ($this->loader) {
  15478. $this->loader->unregister();
  15479. }
  15480. $generator = $this->composer->getAutoloadGenerator();
  15481. if ($event instanceof ScriptEvent) {
  15482. $generator->setDevMode($event->isDevMode());
  15483. }
  15484. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  15485. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  15486. $map = $generator->parseAutoloads($packageMap, $package);
  15487. $this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  15488. $this->loader->register(false);
  15489. return $scripts[$event->getName()];
  15490. }
  15491. protected function isPhpScript($callable)
  15492. {
  15493. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  15494. }
  15495. protected function isComposerScript($callable)
  15496. {
  15497. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  15498. }
  15499. protected function pushEvent(Event $event)
  15500. {
  15501. $eventName = $event->getName();
  15502. if (in_array($eventName, $this->eventStack)) {
  15503. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  15504. }
  15505. return array_push($this->eventStack, $eventName);
  15506. }
  15507. protected function popEvent()
  15508. {
  15509. return array_pop($this->eventStack);
  15510. }
  15511. private function ensureBinDirIsInPath()
  15512. {
  15513. $pathStr = 'PATH';
  15514. if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
  15515. $pathStr = 'Path';
  15516. }
  15517. $binDir = $this->composer->getConfig()->get('bin-dir');
  15518. if (is_dir($binDir)) {
  15519. $binDir = realpath($binDir);
  15520. if (isset($_SERVER[$pathStr]) && !preg_match('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $_SERVER[$pathStr])) {
  15521. Platform::putEnv($pathStr, $binDir.PATH_SEPARATOR.getenv($pathStr));
  15522. }
  15523. }
  15524. }
  15525. }
  15526. <?php
  15527. namespace Composer\EventDispatcher;
  15528. interface EventSubscriberInterface
  15529. {
  15530. public static function getSubscribedEvents();
  15531. }
  15532. <?php
  15533. namespace Composer\EventDispatcher;
  15534. class ScriptExecutionException extends \RuntimeException
  15535. {
  15536. }
  15537. <?php
  15538. namespace Composer\Exception;
  15539. class IrrecoverableDownloadException extends \RuntimeException
  15540. {
  15541. }
  15542. <?php
  15543. namespace Composer\Exception;
  15544. class NoSslException extends \RuntimeException
  15545. {
  15546. }
  15547. <?php
  15548. namespace Composer;
  15549. use Composer\Config\JsonConfigSource;
  15550. use Composer\Json\JsonFile;
  15551. use Composer\IO\IOInterface;
  15552. use Composer\Package\Archiver;
  15553. use Composer\Package\Version\VersionGuesser;
  15554. use Composer\Package\RootPackageInterface;
  15555. use Composer\Repository\RepositoryManager;
  15556. use Composer\Repository\RepositoryFactory;
  15557. use Composer\Util\Filesystem;
  15558. use Composer\Util\Platform;
  15559. use Composer\Util\ProcessExecutor;
  15560. use Composer\Util\HttpDownloader;
  15561. use Composer\Util\Loop;
  15562. use Composer\Util\Silencer;
  15563. use Composer\Plugin\PluginEvents;
  15564. use Composer\EventDispatcher\Event;
  15565. use Seld\JsonLint\DuplicateKeyException;
  15566. use Symfony\Component\Console\Formatter\OutputFormatter;
  15567. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  15568. use Symfony\Component\Console\Output\ConsoleOutput;
  15569. use Composer\EventDispatcher\EventDispatcher;
  15570. use Composer\Autoload\AutoloadGenerator;
  15571. use Composer\Package\Version\VersionParser;
  15572. use Composer\Downloader\TransportException;
  15573. use Composer\Json\JsonValidationException;
  15574. use Composer\Repository\InstalledRepositoryInterface;
  15575. use Seld\JsonLint\JsonParser;
  15576. class Factory
  15577. {
  15578. protected static function getHomeDir()
  15579. {
  15580. $home = getenv('COMPOSER_HOME');
  15581. if ($home) {
  15582. return $home;
  15583. }
  15584. if (Platform::isWindows()) {
  15585. if (!getenv('APPDATA')) {
  15586. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  15587. }
  15588. return rtrim(strtr(getenv('APPDATA'), '\\', '/'), '/') . '/Composer';
  15589. }
  15590. $userDir = self::getUserDir();
  15591. $dirs = array();
  15592. if (self::useXdg()) {
  15593. $xdgConfig = getenv('XDG_CONFIG_HOME');
  15594. if (!$xdgConfig) {
  15595. $xdgConfig = $userDir . '/.config';
  15596. }
  15597. $dirs[] = $xdgConfig . '/composer';
  15598. }
  15599. $dirs[] = $userDir . '/.composer';
  15600. foreach ($dirs as $dir) {
  15601. if (Silencer::call('is_dir', $dir)) {
  15602. return $dir;
  15603. }
  15604. }
  15605. return $dirs[0];
  15606. }
  15607. protected static function getCacheDir($home)
  15608. {
  15609. $cacheDir = getenv('COMPOSER_CACHE_DIR');
  15610. if ($cacheDir) {
  15611. return $cacheDir;
  15612. }
  15613. $homeEnv = getenv('COMPOSER_HOME');
  15614. if ($homeEnv) {
  15615. return $homeEnv . '/cache';
  15616. }
  15617. if (Platform::isWindows()) {
  15618. if ($cacheDir = getenv('LOCALAPPDATA')) {
  15619. $cacheDir .= '/Composer';
  15620. } else {
  15621. $cacheDir = $home . '/cache';
  15622. }
  15623. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  15624. }
  15625. $userDir = self::getUserDir();
  15626. if (PHP_OS === 'Darwin') {
  15627. if (is_dir($home . '/cache') && !is_dir($userDir . '/Library/Caches/composer')) {
  15628. Silencer::call('rename', $home . '/cache', $userDir . '/Library/Caches/composer');
  15629. }
  15630. return $userDir . '/Library/Caches/composer';
  15631. }
  15632. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  15633. return $home . '/cache';
  15634. }
  15635. if (self::useXdg()) {
  15636. $xdgCache = getenv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  15637. return $xdgCache . '/composer';
  15638. }
  15639. return $home . '/cache';
  15640. }
  15641. protected static function getDataDir($home)
  15642. {
  15643. $homeEnv = getenv('COMPOSER_HOME');
  15644. if ($homeEnv) {
  15645. return $homeEnv;
  15646. }
  15647. if (Platform::isWindows()) {
  15648. return strtr($home, '\\', '/');
  15649. }
  15650. $userDir = self::getUserDir();
  15651. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  15652. $xdgData = getenv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  15653. return $xdgData . '/composer';
  15654. }
  15655. return $home;
  15656. }
  15657. public static function createConfig(IOInterface $io = null, $cwd = null)
  15658. {
  15659. $cwd = $cwd ?: (string) getcwd();
  15660. $config = new Config(true, $cwd);
  15661. $home = self::getHomeDir();
  15662. $config->merge(array('config' => array(
  15663. 'home' => $home,
  15664. 'cache-dir' => self::getCacheDir($home),
  15665. 'data-dir' => self::getDataDir($home),
  15666. )));
  15667. $file = new JsonFile($config->get('home').'/config.json');
  15668. if ($file->exists()) {
  15669. if ($io && $io->isDebug()) {
  15670. $io->writeError('Loading config file ' . $file->getPath());
  15671. }
  15672. $config->merge($file->read());
  15673. }
  15674. $config->setConfigSource(new JsonConfigSource($file));
  15675. $htaccessProtect = (bool) $config->get('htaccess-protect');
  15676. if ($htaccessProtect) {
  15677. $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
  15678. foreach ($dirs as $dir) {
  15679. if (!file_exists($dir . '/.htaccess')) {
  15680. if (!is_dir($dir)) {
  15681. Silencer::call('mkdir', $dir, 0777, true);
  15682. }
  15683. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  15684. }
  15685. }
  15686. }
  15687. $file = new JsonFile($config->get('home').'/auth.json');
  15688. if ($file->exists()) {
  15689. if ($io && $io->isDebug()) {
  15690. $io->writeError('Loading config file ' . $file->getPath());
  15691. }
  15692. $config->merge(array('config' => $file->read()));
  15693. }
  15694. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  15695. if ($composerAuthEnv = getenv('COMPOSER_AUTH')) {
  15696. $authData = json_decode($composerAuthEnv, true);
  15697. if (null === $authData) {
  15698. if ($io) {
  15699. $io->writeError('<error>COMPOSER_AUTH environment variable is malformed, should be a valid JSON object</error>');
  15700. }
  15701. } else {
  15702. if ($io && $io->isDebug()) {
  15703. $io->writeError('Loading auth config from COMPOSER_AUTH');
  15704. }
  15705. $config->merge(array('config' => $authData));
  15706. }
  15707. }
  15708. return $config;
  15709. }
  15710. public static function getComposerFile()
  15711. {
  15712. return trim(getenv('COMPOSER')) ?: './composer.json';
  15713. }
  15714. public static function getLockFile($composerFile)
  15715. {
  15716. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  15717. ? substr($composerFile, 0, -4).'lock'
  15718. : $composerFile . '.lock';
  15719. }
  15720. public static function createAdditionalStyles()
  15721. {
  15722. return array(
  15723. 'highlight' => new OutputFormatterStyle('red'),
  15724. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  15725. );
  15726. }
  15727. public static function createOutput()
  15728. {
  15729. $styles = self::createAdditionalStyles();
  15730. $formatter = new OutputFormatter(false, $styles);
  15731. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  15732. }
  15733. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true)
  15734. {
  15735. $cwd = $cwd ?: (string) getcwd();
  15736. if (null === $localConfig) {
  15737. $localConfig = static::getComposerFile();
  15738. }
  15739. if (is_string($localConfig)) {
  15740. $composerFile = $localConfig;
  15741. $file = new JsonFile($localConfig, null, $io);
  15742. if (!$file->exists()) {
  15743. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  15744. $message = 'Composer could not find a composer.json file in '.$cwd;
  15745. } else {
  15746. $message = 'Composer could not find the config file: '.$localConfig;
  15747. }
  15748. $instructions = $fullLoad ? 'To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage' : '';
  15749. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  15750. }
  15751. try {
  15752. $file->validateSchema(JsonFile::LAX_SCHEMA);
  15753. } catch (JsonValidationException $e) {
  15754. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  15755. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  15756. throw new JsonValidationException($message);
  15757. }
  15758. $jsonParser = new JsonParser;
  15759. try {
  15760. $jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
  15761. } catch (DuplicateKeyException $e) {
  15762. $details = $e->getDetails();
  15763. $io->writeError('<warning>Key '.$details['key'].' is a duplicate in '.$localConfig.' at line '.$details['line'].'</warning>');
  15764. }
  15765. $localConfig = $file->read();
  15766. }
  15767. $config = static::createConfig($io, $cwd);
  15768. $config->merge($localConfig);
  15769. if (isset($composerFile)) {
  15770. $io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
  15771. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  15772. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  15773. if ($localAuthFile->exists()) {
  15774. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  15775. $config->merge(array('config' => $localAuthFile->read()));
  15776. $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  15777. }
  15778. }
  15779. $vendorDir = $config->get('vendor-dir');
  15780. $composer = new Composer();
  15781. $composer->setConfig($config);
  15782. if ($fullLoad) {
  15783. $io->loadConfiguration($config);
  15784. if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
  15785. include $installedVersionsPath;
  15786. }
  15787. }
  15788. $httpDownloader = self::createHttpDownloader($io, $config);
  15789. $process = new ProcessExecutor($io);
  15790. $loop = new Loop($httpDownloader, $process);
  15791. $composer->setLoop($loop);
  15792. $dispatcher = new EventDispatcher($composer, $io, $process);
  15793. $composer->setEventDispatcher($dispatcher);
  15794. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  15795. $composer->setRepositoryManager($rm);
  15796. if (!$fullLoad && !isset($localConfig['version'])) {
  15797. $localConfig['version'] = '1.0.0';
  15798. }
  15799. $parser = new VersionParser;
  15800. $guesser = new VersionGuesser($config, $process, $parser);
  15801. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  15802. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  15803. $composer->setPackage($package);
  15804. $this->addLocalRepository($io, $rm, $vendorDir, $package, $process);
  15805. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  15806. $composer->setInstallationManager($im);
  15807. if ($fullLoad) {
  15808. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  15809. $composer->setDownloadManager($dm);
  15810. $generator = new AutoloadGenerator($dispatcher, $io);
  15811. $composer->setAutoloadGenerator($generator);
  15812. $am = $this->createArchiveManager($config, $dm, $loop);
  15813. $composer->setArchiveManager($am);
  15814. }
  15815. $this->createDefaultInstallers($im, $composer, $io, $process);
  15816. if ($fullLoad) {
  15817. $globalComposer = null;
  15818. if (realpath($config->get('home')) !== $cwd) {
  15819. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
  15820. }
  15821. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  15822. $composer->setPluginManager($pm);
  15823. $pm->loadInstalledPlugins();
  15824. }
  15825. if ($fullLoad && isset($composerFile)) {
  15826. $lockFile = self::getLockFile($composerFile);
  15827. $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile), $process);
  15828. $composer->setLocker($locker);
  15829. }
  15830. if ($fullLoad) {
  15831. $initEvent = new Event(PluginEvents::INIT);
  15832. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  15833. $this->purgePackages($rm->getLocalRepository(), $im);
  15834. }
  15835. return $composer;
  15836. }
  15837. public static function createGlobal(IOInterface $io, $disablePlugins = false)
  15838. {
  15839. $factory = new static();
  15840. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, true);
  15841. }
  15842. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage, ProcessExecutor $process = null)
  15843. {
  15844. $fs = null;
  15845. if ($process) {
  15846. $fs = new Filesystem($process);
  15847. }
  15848. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage, $fs));
  15849. }
  15850. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $fullLoad = false)
  15851. {
  15852. $composer = null;
  15853. try {
  15854. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad);
  15855. } catch (\Exception $e) {
  15856. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  15857. }
  15858. return $composer;
  15859. }
  15860. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, EventDispatcher $eventDispatcher = null)
  15861. {
  15862. $cache = null;
  15863. if ($config->get('cache-files-ttl') > 0) {
  15864. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  15865. $cache->setReadOnly($config->get('cache-read-only'));
  15866. }
  15867. $fs = new Filesystem($process);
  15868. $dm = new Downloader\DownloadManager($io, false, $fs);
  15869. switch ($preferred = $config->get('preferred-install')) {
  15870. case 'dist':
  15871. $dm->setPreferDist(true);
  15872. break;
  15873. case 'source':
  15874. $dm->setPreferSource(true);
  15875. break;
  15876. case 'auto':
  15877. default:
  15878. break;
  15879. }
  15880. if (is_array($preferred)) {
  15881. $dm->setPreferences($preferred);
  15882. }
  15883. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  15884. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  15885. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  15886. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  15887. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  15888. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  15889. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  15890. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  15891. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  15892. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  15893. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  15894. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  15895. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  15896. return $dm;
  15897. }
  15898. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  15899. {
  15900. $am = new Archiver\ArchiveManager($dm, $loop);
  15901. $am->addArchiver(new Archiver\ZipArchiver);
  15902. $am->addArchiver(new Archiver\PharArchiver);
  15903. return $am;
  15904. }
  15905. protected function createPluginManager(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  15906. {
  15907. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  15908. }
  15909. public function createInstallationManager(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  15910. {
  15911. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  15912. }
  15913. protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  15914. {
  15915. $fs = new Filesystem($process);
  15916. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs);
  15917. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  15918. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  15919. $im->addInstaller(new Installer\MetapackageInstaller($io));
  15920. }
  15921. protected function purgePackages(InstalledRepositoryInterface $repo, Installer\InstallationManager $im)
  15922. {
  15923. foreach ($repo->getPackages() as $package) {
  15924. if (!$im->isPackageInstalled($repo, $package)) {
  15925. $repo->removePackage($package);
  15926. }
  15927. }
  15928. }
  15929. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io)
  15930. {
  15931. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  15932. }
  15933. public static function create(IOInterface $io, $config = null, $disablePlugins = false)
  15934. {
  15935. $factory = new static();
  15936. return $factory->createComposer($io, $config, $disablePlugins);
  15937. }
  15938. public static function createHttpDownloader(IOInterface $io, Config $config, $options = array())
  15939. {
  15940. static $warned = false;
  15941. $disableTls = false;
  15942. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  15943. $warned = true;
  15944. $disableTls = !extension_loaded('openssl');
  15945. } elseif ($config->get('disable-tls') === true) {
  15946. if (!$warned) {
  15947. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  15948. }
  15949. $warned = true;
  15950. $disableTls = true;
  15951. } elseif (!extension_loaded('openssl')) {
  15952. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  15953. . '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.');
  15954. }
  15955. $httpDownloaderOptions = array();
  15956. if ($disableTls === false) {
  15957. if ($config->get('cafile')) {
  15958. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  15959. }
  15960. if ($config->get('capath')) {
  15961. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  15962. }
  15963. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  15964. }
  15965. try {
  15966. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  15967. } catch (TransportException $e) {
  15968. if (false !== strpos($e->getMessage(), 'cafile')) {
  15969. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  15970. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  15971. if (PHP_VERSION_ID < 50600) {
  15972. $io->write('<error>It is recommended you upgrade to PHP 5.6+ which can detect your system CA file automatically.</error>');
  15973. }
  15974. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  15975. }
  15976. throw $e;
  15977. }
  15978. return $httpDownloader;
  15979. }
  15980. private static function useXdg()
  15981. {
  15982. foreach (array_keys($_SERVER) as $key) {
  15983. if (strpos($key, 'XDG_') === 0) {
  15984. return true;
  15985. }
  15986. }
  15987. if (Silencer::call('is_dir', '/etc/xdg')) {
  15988. return true;
  15989. }
  15990. return false;
  15991. }
  15992. private static function getUserDir()
  15993. {
  15994. $home = getenv('HOME');
  15995. if (!$home) {
  15996. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  15997. }
  15998. return rtrim(strtr($home, '\\', '/'), '/');
  15999. }
  16000. }
  16001. <?php
  16002. namespace Composer\IO;
  16003. use Composer\Config;
  16004. use Composer\Util\ProcessExecutor;
  16005. use Psr\Log\LogLevel;
  16006. abstract class BaseIO implements IOInterface
  16007. {
  16008. protected $authentications = array();
  16009. public function getAuthentications()
  16010. {
  16011. return $this->authentications;
  16012. }
  16013. public function resetAuthentications()
  16014. {
  16015. $this->authentications = array();
  16016. }
  16017. public function hasAuthentication($repositoryName)
  16018. {
  16019. return isset($this->authentications[$repositoryName]);
  16020. }
  16021. public function getAuthentication($repositoryName)
  16022. {
  16023. if (isset($this->authentications[$repositoryName])) {
  16024. return $this->authentications[$repositoryName];
  16025. }
  16026. return array('username' => null, 'password' => null);
  16027. }
  16028. public function setAuthentication($repositoryName, $username, $password = null)
  16029. {
  16030. $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
  16031. }
  16032. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  16033. {
  16034. $this->write($messages, $newline, $verbosity);
  16035. }
  16036. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  16037. {
  16038. $this->writeError($messages, $newline, $verbosity);
  16039. }
  16040. protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
  16041. {
  16042. if ($this->hasAuthentication($repositoryName)) {
  16043. $auth = $this->getAuthentication($repositoryName);
  16044. if ($auth['username'] === $username && $auth['password'] === $password) {
  16045. return;
  16046. }
  16047. $this->writeError(
  16048. sprintf(
  16049. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  16050. $repositoryName
  16051. )
  16052. );
  16053. }
  16054. $this->setAuthentication($repositoryName, $username, $password);
  16055. }
  16056. public function loadConfiguration(Config $config)
  16057. {
  16058. $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
  16059. $githubOauth = $config->get('github-oauth') ?: array();
  16060. $gitlabOauth = $config->get('gitlab-oauth') ?: array();
  16061. $gitlabToken = $config->get('gitlab-token') ?: array();
  16062. $httpBasic = $config->get('http-basic') ?: array();
  16063. $bearerToken = $config->get('bearer') ?: array();
  16064. foreach ($bitbucketOauth as $domain => $cred) {
  16065. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  16066. }
  16067. foreach ($githubOauth as $domain => $token) {
  16068. if (!preg_match('{^[.A-Za-z0-9_]+$}', $token)) {
  16069. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  16070. }
  16071. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  16072. }
  16073. foreach ($gitlabOauth as $domain => $token) {
  16074. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  16075. }
  16076. foreach ($gitlabToken as $domain => $token) {
  16077. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  16078. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  16079. $this->checkAndSetAuthentication($domain, $username, $password);
  16080. }
  16081. foreach ($httpBasic as $domain => $cred) {
  16082. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  16083. }
  16084. foreach ($bearerToken as $domain => $token) {
  16085. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  16086. }
  16087. ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
  16088. }
  16089. public function emergency($message, array $context = array())
  16090. {
  16091. $this->log(LogLevel::EMERGENCY, $message, $context);
  16092. }
  16093. public function alert($message, array $context = array())
  16094. {
  16095. $this->log(LogLevel::ALERT, $message, $context);
  16096. }
  16097. public function critical($message, array $context = array())
  16098. {
  16099. $this->log(LogLevel::CRITICAL, $message, $context);
  16100. }
  16101. public function error($message, array $context = array())
  16102. {
  16103. $this->log(LogLevel::ERROR, $message, $context);
  16104. }
  16105. public function warning($message, array $context = array())
  16106. {
  16107. $this->log(LogLevel::WARNING, $message, $context);
  16108. }
  16109. public function notice($message, array $context = array())
  16110. {
  16111. $this->log(LogLevel::NOTICE, $message, $context);
  16112. }
  16113. public function info($message, array $context = array())
  16114. {
  16115. $this->log(LogLevel::INFO, $message, $context);
  16116. }
  16117. public function debug($message, array $context = array())
  16118. {
  16119. $this->log(LogLevel::DEBUG, $message, $context);
  16120. }
  16121. public function log($level, $message, array $context = array())
  16122. {
  16123. if (in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
  16124. $this->writeError('<error>'.$message.'</error>');
  16125. } elseif ($level === LogLevel::WARNING) {
  16126. $this->writeError('<warning>'.$message.'</warning>');
  16127. } elseif ($level === LogLevel::NOTICE) {
  16128. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  16129. } elseif ($level === LogLevel::INFO) {
  16130. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  16131. } else {
  16132. $this->writeError($message, true, self::DEBUG);
  16133. }
  16134. }
  16135. }
  16136. <?php
  16137. namespace Composer\IO;
  16138. use Symfony\Component\Console\Helper\QuestionHelper;
  16139. use Symfony\Component\Console\Output\StreamOutput;
  16140. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  16141. use Symfony\Component\Console\Input\StreamableInputInterface;
  16142. use Symfony\Component\Console\Input\StringInput;
  16143. use Symfony\Component\Console\Helper\HelperSet;
  16144. class BufferIO extends ConsoleIO
  16145. {
  16146. protected $input;
  16147. protected $output;
  16148. public function __construct($input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
  16149. {
  16150. $input = new StringInput($input);
  16151. $input->setInteractive(false);
  16152. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  16153. parent::__construct($input, $output, new HelperSet(array(
  16154. new QuestionHelper(),
  16155. )));
  16156. }
  16157. public function getOutput()
  16158. {
  16159. fseek($this->output->getStream(), 0);
  16160. $output = stream_get_contents($this->output->getStream());
  16161. $output = preg_replace_callback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches) {
  16162. $pre = strip_tags($matches[1]);
  16163. if (strlen($pre) === strlen($matches[2])) {
  16164. return '';
  16165. }
  16166. return rtrim($matches[1])."\n";
  16167. }, $output);
  16168. return $output;
  16169. }
  16170. public function setUserInputs(array $inputs)
  16171. {
  16172. if (!$this->input instanceof StreamableInputInterface) {
  16173. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  16174. }
  16175. $this->input->setStream($this->createStream($inputs));
  16176. $this->input->setInteractive(true);
  16177. }
  16178. private function createStream(array $inputs)
  16179. {
  16180. $stream = fopen('php://memory', 'r+');
  16181. foreach ($inputs as $input) {
  16182. fwrite($stream, $input.PHP_EOL);
  16183. }
  16184. rewind($stream);
  16185. return $stream;
  16186. }
  16187. }
  16188. <?php
  16189. namespace Composer\IO;
  16190. use Composer\Question\StrictConfirmationQuestion;
  16191. use Symfony\Component\Console\Helper\HelperSet;
  16192. use Symfony\Component\Console\Helper\ProgressBar;
  16193. use Symfony\Component\Console\Input\InputInterface;
  16194. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  16195. use Symfony\Component\Console\Output\OutputInterface;
  16196. use Symfony\Component\Console\Question\ChoiceQuestion;
  16197. use Symfony\Component\Console\Question\Question;
  16198. class ConsoleIO extends BaseIO
  16199. {
  16200. protected $input;
  16201. protected $output;
  16202. protected $helperSet;
  16203. protected $lastMessage = '';
  16204. protected $lastMessageErr = '';
  16205. private $startTime;
  16206. private $verbosityMap;
  16207. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  16208. {
  16209. $this->input = $input;
  16210. $this->output = $output;
  16211. $this->helperSet = $helperSet;
  16212. $this->verbosityMap = array(
  16213. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  16214. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  16215. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  16216. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  16217. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  16218. );
  16219. }
  16220. public function enableDebugging($startTime)
  16221. {
  16222. $this->startTime = $startTime;
  16223. }
  16224. public function isInteractive()
  16225. {
  16226. return $this->input->isInteractive();
  16227. }
  16228. public function isDecorated()
  16229. {
  16230. return $this->output->isDecorated();
  16231. }
  16232. public function isVerbose()
  16233. {
  16234. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
  16235. }
  16236. public function isVeryVerbose()
  16237. {
  16238. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE;
  16239. }
  16240. public function isDebug()
  16241. {
  16242. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG;
  16243. }
  16244. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  16245. {
  16246. $this->doWrite($messages, $newline, false, $verbosity);
  16247. }
  16248. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  16249. {
  16250. $this->doWrite($messages, $newline, true, $verbosity);
  16251. }
  16252. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  16253. {
  16254. $this->doWrite($messages, $newline, false, $verbosity, true);
  16255. }
  16256. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  16257. {
  16258. $this->doWrite($messages, $newline, true, $verbosity, true);
  16259. }
  16260. private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false)
  16261. {
  16262. $sfVerbosity = $this->verbosityMap[$verbosity];
  16263. if ($sfVerbosity > $this->output->getVerbosity()) {
  16264. return;
  16265. }
  16266. if ($raw) {
  16267. if ($sfVerbosity === OutputInterface::OUTPUT_NORMAL) {
  16268. $sfVerbosity = OutputInterface::OUTPUT_RAW;
  16269. } else {
  16270. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  16271. }
  16272. }
  16273. if (null !== $this->startTime) {
  16274. $memoryUsage = memory_get_usage() / 1024 / 1024;
  16275. $timeSpent = microtime(true) - $this->startTime;
  16276. $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) {
  16277. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  16278. }, (array) $messages);
  16279. }
  16280. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  16281. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  16282. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  16283. return;
  16284. }
  16285. $this->output->write($messages, $newline, $sfVerbosity);
  16286. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  16287. }
  16288. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  16289. {
  16290. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  16291. }
  16292. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  16293. {
  16294. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  16295. }
  16296. private function doOverwrite($messages, $newline, $size, $stderr, $verbosity)
  16297. {
  16298. $messages = implode($newline ? "\n" : '', (array) $messages);
  16299. if (!isset($size)) {
  16300. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  16301. }
  16302. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  16303. $this->doWrite($messages, false, $stderr, $verbosity);
  16304. $fill = $size - strlen(strip_tags($messages));
  16305. if ($fill > 0) {
  16306. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  16307. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  16308. }
  16309. if ($newline) {
  16310. $this->doWrite('', true, $stderr, $verbosity);
  16311. }
  16312. if ($stderr) {
  16313. $this->lastMessageErr = $messages;
  16314. } else {
  16315. $this->lastMessage = $messages;
  16316. }
  16317. }
  16318. public function getProgressBar($max = 0)
  16319. {
  16320. return new ProgressBar($this->getErrorOutput(), $max);
  16321. }
  16322. public function ask($question, $default = null)
  16323. {
  16324. $helper = $this->helperSet->get('question');
  16325. $question = new Question($question, $default);
  16326. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  16327. }
  16328. public function askConfirmation($question, $default = true)
  16329. {
  16330. $helper = $this->helperSet->get('question');
  16331. $question = new StrictConfirmationQuestion($question, $default);
  16332. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  16333. }
  16334. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  16335. {
  16336. $helper = $this->helperSet->get('question');
  16337. $question = new Question($question, $default);
  16338. $question->setValidator($validator);
  16339. $question->setMaxAttempts($attempts);
  16340. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  16341. }
  16342. public function askAndHideAnswer($question)
  16343. {
  16344. $helper = $this->helperSet->get('question');
  16345. $question = new Question($question);
  16346. $question->setHidden(true);
  16347. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  16348. }
  16349. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  16350. {
  16351. $helper = $this->helperSet->get('question');
  16352. $question = new ChoiceQuestion($question, $choices, $default);
  16353. $question->setMaxAttempts($attempts ?: null);
  16354. $question->setErrorMessage($errorMessage);
  16355. $question->setMultiselect($multiselect);
  16356. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  16357. if (!is_array($result)) {
  16358. return (string) array_search($result, $choices, true);
  16359. }
  16360. $results = array();
  16361. foreach ($choices as $index => $choice) {
  16362. if (in_array($choice, $result, true)) {
  16363. $results[] = (string) $index;
  16364. }
  16365. }
  16366. return $results;
  16367. }
  16368. private function getErrorOutput()
  16369. {
  16370. if ($this->output instanceof ConsoleOutputInterface) {
  16371. return $this->output->getErrorOutput();
  16372. }
  16373. return $this->output;
  16374. }
  16375. }
  16376. <?php
  16377. namespace Composer\IO;
  16378. use Composer\Config;
  16379. use Psr\Log\LoggerInterface;
  16380. interface IOInterface extends LoggerInterface
  16381. {
  16382. const QUIET = 1;
  16383. const NORMAL = 2;
  16384. const VERBOSE = 4;
  16385. const VERY_VERBOSE = 8;
  16386. const DEBUG = 16;
  16387. public function isInteractive();
  16388. public function isVerbose();
  16389. public function isVeryVerbose();
  16390. public function isDebug();
  16391. public function isDecorated();
  16392. public function write($messages, $newline = true, $verbosity = self::NORMAL);
  16393. public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
  16394. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL);
  16395. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL);
  16396. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  16397. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  16398. public function ask($question, $default = null);
  16399. public function askConfirmation($question, $default = true);
  16400. public function askAndValidate($question, $validator, $attempts = null, $default = null);
  16401. public function askAndHideAnswer($question);
  16402. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
  16403. public function getAuthentications();
  16404. public function hasAuthentication($repositoryName);
  16405. public function getAuthentication($repositoryName);
  16406. public function setAuthentication($repositoryName, $username, $password = null);
  16407. public function loadConfiguration(Config $config);
  16408. }
  16409. <?php
  16410. namespace Composer\IO;
  16411. class NullIO extends BaseIO
  16412. {
  16413. public function isInteractive()
  16414. {
  16415. return false;
  16416. }
  16417. public function isVerbose()
  16418. {
  16419. return false;
  16420. }
  16421. public function isVeryVerbose()
  16422. {
  16423. return false;
  16424. }
  16425. public function isDebug()
  16426. {
  16427. return false;
  16428. }
  16429. public function isDecorated()
  16430. {
  16431. return false;
  16432. }
  16433. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  16434. {
  16435. }
  16436. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  16437. {
  16438. }
  16439. public function overwrite($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  16440. {
  16441. }
  16442. public function overwriteError($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  16443. {
  16444. }
  16445. public function ask($question, $default = null)
  16446. {
  16447. return $default;
  16448. }
  16449. public function askConfirmation($question, $default = true)
  16450. {
  16451. return $default;
  16452. }
  16453. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  16454. {
  16455. return $default;
  16456. }
  16457. public function askAndHideAnswer($question)
  16458. {
  16459. return null;
  16460. }
  16461. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  16462. {
  16463. return $default;
  16464. }
  16465. }
  16466. <?php
  16467. namespace Composer;
  16468. use Composer\Autoload\AutoloadGenerator;
  16469. use Composer\Console\GithubActionError;
  16470. use Composer\DependencyResolver\DefaultPolicy;
  16471. use Composer\DependencyResolver\LocalRepoTransaction;
  16472. use Composer\DependencyResolver\LockTransaction;
  16473. use Composer\DependencyResolver\Operation\UpdateOperation;
  16474. use Composer\DependencyResolver\Operation\InstallOperation;
  16475. use Composer\DependencyResolver\Operation\UninstallOperation;
  16476. use Composer\DependencyResolver\Pool;
  16477. use Composer\DependencyResolver\Request;
  16478. use Composer\DependencyResolver\Solver;
  16479. use Composer\DependencyResolver\SolverProblemsException;
  16480. use Composer\DependencyResolver\PolicyInterface;
  16481. use Composer\Downloader\DownloadManager;
  16482. use Composer\EventDispatcher\EventDispatcher;
  16483. use Composer\Installer\InstallationManager;
  16484. use Composer\Installer\InstallerEvents;
  16485. use Composer\Installer\SuggestedPackagesReporter;
  16486. use Composer\IO\IOInterface;
  16487. use Composer\Package\AliasPackage;
  16488. use Composer\Package\RootAliasPackage;
  16489. use Composer\Package\BasePackage;
  16490. use Composer\Package\CompletePackage;
  16491. use Composer\Package\CompletePackageInterface;
  16492. use Composer\Package\Link;
  16493. use Composer\Package\Loader\ArrayLoader;
  16494. use Composer\Package\Dumper\ArrayDumper;
  16495. use Composer\Package\Version\VersionParser;
  16496. use Composer\Package\Package;
  16497. use Composer\Repository\ArrayRepository;
  16498. use Composer\Repository\RepositorySet;
  16499. use Composer\Repository\CompositeRepository;
  16500. use Composer\Semver\Constraint\Constraint;
  16501. use Composer\Package\Locker;
  16502. use Composer\Package\RootPackageInterface;
  16503. use Composer\Repository\InstalledArrayRepository;
  16504. use Composer\Repository\InstalledRepositoryInterface;
  16505. use Composer\Repository\InstalledRepository;
  16506. use Composer\Repository\RootPackageRepository;
  16507. use Composer\Repository\PlatformRepository;
  16508. use Composer\Repository\RepositoryInterface;
  16509. use Composer\Repository\RepositoryManager;
  16510. use Composer\Repository\LockArrayRepository;
  16511. use Composer\Script\ScriptEvents;
  16512. use Composer\Util\Platform;
  16513. class Installer
  16514. {
  16515. const ERROR_NONE = 0;
  16516. const ERROR_GENERIC_FAILURE = 1;
  16517. const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3;
  16518. const ERROR_LOCK_FILE_INVALID = 4;
  16519. const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  16520. protected $io;
  16521. protected $config;
  16522. protected $package;
  16523. protected $fixedRootPackage;
  16524. protected $downloadManager;
  16525. protected $repositoryManager;
  16526. protected $locker;
  16527. protected $installationManager;
  16528. protected $eventDispatcher;
  16529. protected $autoloadGenerator;
  16530. protected $preferSource = false;
  16531. protected $preferDist = false;
  16532. protected $optimizeAutoloader = false;
  16533. protected $classMapAuthoritative = false;
  16534. protected $apcuAutoloader = false;
  16535. protected $apcuAutoloaderPrefix = null;
  16536. protected $devMode = false;
  16537. protected $dryRun = false;
  16538. protected $verbose = false;
  16539. protected $update = false;
  16540. protected $install = true;
  16541. protected $dumpAutoloader = true;
  16542. protected $runScripts = true;
  16543. protected $ignorePlatformReqs = false;
  16544. protected $preferStable = false;
  16545. protected $preferLowest = false;
  16546. protected $writeLock;
  16547. protected $executeOperations = true;
  16548. protected $updateMirrors = false;
  16549. protected $updateAllowList = null;
  16550. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  16551. protected $suggestedPackagesReporter;
  16552. protected $additionalFixedRepository;
  16553. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  16554. {
  16555. $this->io = $io;
  16556. $this->config = $config;
  16557. $this->package = $package;
  16558. $this->downloadManager = $downloadManager;
  16559. $this->repositoryManager = $repositoryManager;
  16560. $this->locker = $locker;
  16561. $this->installationManager = $installationManager;
  16562. $this->eventDispatcher = $eventDispatcher;
  16563. $this->autoloadGenerator = $autoloadGenerator;
  16564. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  16565. $this->writeLock = $config->get('lock');
  16566. }
  16567. public function run()
  16568. {
  16569. gc_collect_cycles();
  16570. gc_disable();
  16571. if ($this->updateAllowList && $this->updateMirrors) {
  16572. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  16573. }
  16574. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  16575. if (!$this->update && !$this->locker->isLocked()) {
  16576. $this->io->writeError('<warning>No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.</warning>');
  16577. $this->update = true;
  16578. }
  16579. if ($this->dryRun) {
  16580. $this->verbose = true;
  16581. $this->runScripts = false;
  16582. $this->executeOperations = false;
  16583. $this->writeLock = false;
  16584. $this->dumpAutoloader = false;
  16585. $this->mockLocalRepositories($this->repositoryManager);
  16586. }
  16587. if ($this->update && !$this->install) {
  16588. $this->dumpAutoloader = false;
  16589. }
  16590. if ($this->runScripts) {
  16591. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  16592. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  16593. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  16594. }
  16595. $this->downloadManager->setPreferSource($this->preferSource);
  16596. $this->downloadManager->setPreferDist($this->preferDist);
  16597. $localRepo = $this->repositoryManager->getLocalRepository();
  16598. try {
  16599. if ($this->update) {
  16600. $res = $this->doUpdate($localRepo, $this->install);
  16601. } else {
  16602. $res = $this->doInstall($localRepo);
  16603. }
  16604. if ($res !== 0) {
  16605. return $res;
  16606. }
  16607. } catch (\Exception $e) {
  16608. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  16609. $this->installationManager->notifyInstalls($this->io);
  16610. }
  16611. throw $e;
  16612. }
  16613. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  16614. $this->installationManager->notifyInstalls($this->io);
  16615. }
  16616. if ($this->update) {
  16617. $installedRepo = new InstalledRepository(array(
  16618. $this->locker->getLockedRepository($this->devMode),
  16619. $this->createPlatformRepo(false),
  16620. new RootPackageRepository(clone $this->package),
  16621. ));
  16622. if ($isFreshInstall) {
  16623. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  16624. }
  16625. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  16626. }
  16627. $lockedRepository = $this->locker->getLockedRepository(true);
  16628. foreach ($lockedRepository->getPackages() as $package) {
  16629. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  16630. continue;
  16631. }
  16632. $replacement = is_string($package->getReplacementPackage())
  16633. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  16634. : 'No replacement was suggested';
  16635. $this->io->writeError(
  16636. sprintf(
  16637. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  16638. $package->getPrettyName(),
  16639. $replacement
  16640. )
  16641. );
  16642. }
  16643. if ($this->dumpAutoloader) {
  16644. if ($this->optimizeAutoloader) {
  16645. $this->io->writeError('<info>Generating optimized autoload files</info>');
  16646. } else {
  16647. $this->io->writeError('<info>Generating autoload files</info>');
  16648. }
  16649. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  16650. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  16651. $this->autoloadGenerator->setRunScripts($this->runScripts);
  16652. $this->autoloadGenerator->setIgnorePlatformRequirements($this->ignorePlatformReqs);
  16653. $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
  16654. }
  16655. if ($this->install && $this->executeOperations) {
  16656. foreach ($localRepo->getPackages() as $package) {
  16657. $this->installationManager->ensureBinariesPresence($package);
  16658. }
  16659. }
  16660. $fundingCount = 0;
  16661. foreach ($localRepo->getPackages() as $package) {
  16662. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  16663. $fundingCount++;
  16664. }
  16665. }
  16666. if ($fundingCount) {
  16667. $this->io->writeError(array(
  16668. sprintf(
  16669. "<info>%d package%s you are using %s looking for funding.</info>",
  16670. $fundingCount,
  16671. 1 === $fundingCount ? '' : 's',
  16672. 1 === $fundingCount ? 'is' : 'are'
  16673. ),
  16674. '<info>Use the `composer fund` command to find out more!</info>',
  16675. ));
  16676. }
  16677. if ($this->runScripts) {
  16678. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  16679. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  16680. }
  16681. if (!defined('HHVM_VERSION')) {
  16682. gc_enable();
  16683. }
  16684. return 0;
  16685. }
  16686. protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall)
  16687. {
  16688. $platformRepo = $this->createPlatformRepo(true);
  16689. $aliases = $this->getRootAliases(true);
  16690. $lockedRepository = null;
  16691. try {
  16692. if ($this->locker->isLocked()) {
  16693. $lockedRepository = $this->locker->getLockedRepository(true);
  16694. }
  16695. } catch (\Seld\JsonLint\ParsingException $e) {
  16696. if ($this->updateAllowList || $this->updateMirrors) {
  16697. throw $e;
  16698. }
  16699. }
  16700. if (($this->updateAllowList || $this->updateMirrors) && !$lockedRepository) {
  16701. $this->io->writeError('<error>Cannot update ' . ($this->updateMirrors ? 'lock file information' : 'only a partial set of packages') . ' without a lock file present. Run `composer update` to generate a lock file.</error>', true, IOInterface::QUIET);
  16702. return self::ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE;
  16703. }
  16704. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  16705. $policy = $this->createPolicy(true);
  16706. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  16707. $repositories = $this->repositoryManager->getRepositories();
  16708. foreach ($repositories as $repository) {
  16709. $repositorySet->addRepository($repository);
  16710. }
  16711. if ($lockedRepository) {
  16712. $repositorySet->addRepository($lockedRepository);
  16713. }
  16714. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  16715. $this->requirePackagesForUpdate($request, $lockedRepository, true);
  16716. if ($this->updateAllowList) {
  16717. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  16718. }
  16719. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  16720. $this->io->writeError('<info>Updating dependencies</info>');
  16721. $solver = new Solver($policy, $pool, $this->io);
  16722. try {
  16723. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  16724. $ruleSetSize = $solver->getRuleSetSize();
  16725. $solver = null;
  16726. } catch (SolverProblemsException $e) {
  16727. $err = 'Your requirements could not be resolved to an installable set of packages.';
  16728. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  16729. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  16730. $this->io->writeError($prettyProblem);
  16731. if (!$this->devMode) {
  16732. $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);
  16733. }
  16734. $ghe = new GithubActionError($this->io);
  16735. $ghe->emit($err."\n".$prettyProblem);
  16736. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  16737. }
  16738. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  16739. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  16740. if (!$lockTransaction->getOperations()) {
  16741. $this->io->writeError('Nothing to modify in lock file');
  16742. }
  16743. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy, $lockedRepository);
  16744. if ($exitCode !== 0) {
  16745. return $exitCode;
  16746. }
  16747. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  16748. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  16749. $installsUpdates = $uninstalls = array();
  16750. if ($lockTransaction->getOperations()) {
  16751. $installNames = $updateNames = $uninstallNames = array();
  16752. foreach ($lockTransaction->getOperations() as $operation) {
  16753. if ($operation instanceof InstallOperation) {
  16754. $installsUpdates[] = $operation;
  16755. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  16756. } elseif ($operation instanceof UpdateOperation) {
  16757. if ($this->updateMirrors
  16758. && $operation->getInitialPackage()->getName() == $operation->getTargetPackage()->getName()
  16759. && $operation->getInitialPackage()->getVersion() == $operation->getTargetPackage()->getVersion()
  16760. ) {
  16761. continue;
  16762. }
  16763. $installsUpdates[] = $operation;
  16764. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  16765. } elseif ($operation instanceof UninstallOperation) {
  16766. $uninstalls[] = $operation;
  16767. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  16768. }
  16769. }
  16770. $this->io->writeError(sprintf(
  16771. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  16772. count($installNames),
  16773. 1 === count($installNames) ? '' : 's',
  16774. count($updateNames),
  16775. 1 === count($updateNames) ? '' : 's',
  16776. count($uninstalls),
  16777. 1 === count($uninstalls) ? '' : 's'
  16778. ));
  16779. if ($installNames) {
  16780. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  16781. }
  16782. if ($updateNames) {
  16783. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  16784. }
  16785. if ($uninstalls) {
  16786. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  16787. }
  16788. }
  16789. $sortByName = function ($a, $b) {
  16790. if ($a instanceof UpdateOperation) {
  16791. $a = $a->getTargetPackage()->getName();
  16792. } else {
  16793. $a = $a->getPackage()->getName();
  16794. }
  16795. if ($b instanceof UpdateOperation) {
  16796. $b = $b->getTargetPackage()->getName();
  16797. } else {
  16798. $b = $b->getPackage()->getName();
  16799. }
  16800. return strcmp($a, $b);
  16801. };
  16802. usort($uninstalls, $sortByName);
  16803. usort($installsUpdates, $sortByName);
  16804. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  16805. if ($operation instanceof InstallOperation) {
  16806. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  16807. }
  16808. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  16809. $this->io->writeError(' - ' . $operation->show(true));
  16810. }
  16811. }
  16812. $updatedLock = $this->locker->setLockData(
  16813. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  16814. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  16815. $platformReqs,
  16816. $platformDevReqs,
  16817. $lockTransaction->getAliases($aliases),
  16818. $this->package->getMinimumStability(),
  16819. $this->package->getStabilityFlags(),
  16820. $this->preferStable || $this->package->getPreferStable(),
  16821. $this->preferLowest,
  16822. $this->config->get('platform') ?: array(),
  16823. $this->writeLock && $this->executeOperations
  16824. );
  16825. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  16826. $this->io->writeError('<info>Writing lock file</info>');
  16827. }
  16828. if ($this->executeOperations && count($lockTransaction->getOperations()) > 0) {
  16829. $vendorDir = $this->config->get('vendor-dir');
  16830. if (is_dir($vendorDir)) {
  16831. @touch($vendorDir);
  16832. }
  16833. }
  16834. if ($doInstall) {
  16835. return $this->doInstall($localRepo, true);
  16836. }
  16837. return 0;
  16838. }
  16839. protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null)
  16840. {
  16841. if (!$this->package->getDevRequires()) {
  16842. return 0;
  16843. }
  16844. $resultRepo = new ArrayRepository(array());
  16845. $loader = new ArrayLoader(null, true);
  16846. $dumper = new ArrayDumper();
  16847. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  16848. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  16849. }
  16850. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  16851. $repositorySet->addRepository($resultRepo);
  16852. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  16853. $this->requirePackagesForUpdate($request, $lockedRepository, false);
  16854. $pool = $repositorySet->createPoolWithAllPackages();
  16855. $solver = new Solver($policy, $pool, $this->io);
  16856. try {
  16857. $nonDevLockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  16858. $solver = null;
  16859. } catch (SolverProblemsException $e) {
  16860. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  16861. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  16862. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  16863. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  16864. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  16865. $this->io->writeError($prettyProblem);
  16866. $ghe = new GithubActionError($this->io);
  16867. $ghe->emit($err."\n".$prettyProblem);
  16868. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  16869. }
  16870. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  16871. return 0;
  16872. }
  16873. protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false)
  16874. {
  16875. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  16876. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  16877. if (!$alreadySolved) {
  16878. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  16879. $platformRepo = $this->createPlatformRepo(false);
  16880. $policy = $this->createPolicy(false);
  16881. $repositorySet = $this->createRepositorySet(false, $platformRepo, array(), $lockedRepository);
  16882. $repositorySet->addRepository($lockedRepository);
  16883. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  16884. if (!$this->locker->isFresh()) {
  16885. $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);
  16886. }
  16887. foreach ($lockedRepository->getPackages() as $package) {
  16888. $request->fixLockedPackage($package);
  16889. }
  16890. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  16891. $request->requireName($link->getTarget(), $link->getConstraint());
  16892. }
  16893. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  16894. $solver = new Solver($policy, $pool, $this->io);
  16895. try {
  16896. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  16897. $solver = null;
  16898. if (0 !== count($lockTransaction->getOperations())) {
  16899. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  16900. return self::ERROR_LOCK_FILE_INVALID;
  16901. }
  16902. } catch (SolverProblemsException $e) {
  16903. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  16904. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  16905. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  16906. $this->io->writeError($prettyProblem);
  16907. $ghe = new GithubActionError($this->io);
  16908. $ghe->emit($err."\n".$prettyProblem);
  16909. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  16910. }
  16911. }
  16912. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  16913. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  16914. if (!$localRepoTransaction->getOperations()) {
  16915. $this->io->writeError('Nothing to install, update or remove');
  16916. }
  16917. if ($localRepoTransaction->getOperations()) {
  16918. $installs = $updates = $uninstalls = array();
  16919. foreach ($localRepoTransaction->getOperations() as $operation) {
  16920. if ($operation instanceof InstallOperation) {
  16921. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  16922. } elseif ($operation instanceof UpdateOperation) {
  16923. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  16924. } elseif ($operation instanceof UninstallOperation) {
  16925. $uninstalls[] = $operation->getPackage()->getPrettyName();
  16926. }
  16927. }
  16928. $this->io->writeError(sprintf(
  16929. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  16930. count($installs),
  16931. 1 === count($installs) ? '' : 's',
  16932. count($updates),
  16933. 1 === count($updates) ? '' : 's',
  16934. count($uninstalls),
  16935. 1 === count($uninstalls) ? '' : 's'
  16936. ));
  16937. if ($installs) {
  16938. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  16939. }
  16940. if ($updates) {
  16941. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  16942. }
  16943. if ($uninstalls) {
  16944. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  16945. }
  16946. }
  16947. if ($this->executeOperations) {
  16948. $localRepo->setDevPackageNames($this->locker->getDevPackageNames());
  16949. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
  16950. } else {
  16951. foreach ($localRepoTransaction->getOperations() as $operation) {
  16952. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  16953. $this->io->writeError(' - ' . $operation->show(false));
  16954. }
  16955. }
  16956. }
  16957. return 0;
  16958. }
  16959. protected function createPlatformRepo($forUpdate)
  16960. {
  16961. if ($forUpdate) {
  16962. $platformOverrides = $this->config->get('platform') ?: array();
  16963. } else {
  16964. $platformOverrides = $this->locker->getPlatformOverrides();
  16965. }
  16966. return new PlatformRepository(array(), $platformOverrides);
  16967. }
  16968. private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null)
  16969. {
  16970. if ($forUpdate) {
  16971. $minimumStability = $this->package->getMinimumStability();
  16972. $stabilityFlags = $this->package->getStabilityFlags();
  16973. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  16974. } else {
  16975. $minimumStability = $this->locker->getMinimumStability();
  16976. $stabilityFlags = $this->locker->getStabilityFlags();
  16977. $requires = array();
  16978. foreach ($lockedRepository->getPackages() as $package) {
  16979. $constraint = new Constraint('=', $package->getVersion());
  16980. $constraint->setPrettyString($package->getPrettyVersion());
  16981. $requires[$package->getName()] = $constraint;
  16982. }
  16983. }
  16984. $rootRequires = array();
  16985. foreach ($requires as $req => $constraint) {
  16986. if ((true === $this->ignorePlatformReqs || (is_array($this->ignorePlatformReqs) && in_array($req, $this->ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($req)) {
  16987. continue;
  16988. }
  16989. if ($constraint instanceof Link) {
  16990. $rootRequires[$req] = $constraint->getConstraint();
  16991. } else {
  16992. $rootRequires[$req] = $constraint;
  16993. }
  16994. }
  16995. $this->fixedRootPackage = clone $this->package;
  16996. $this->fixedRootPackage->setRequires(array());
  16997. $this->fixedRootPackage->setDevRequires(array());
  16998. $stabilityFlags[$this->package->getName()] = BasePackage::$stabilities[VersionParser::parseStability($this->package->getVersion())];
  16999. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires);
  17000. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  17001. $repositorySet->addRepository($platformRepo);
  17002. if ($this->additionalFixedRepository) {
  17003. $additionalFixedRepositories = $this->additionalFixedRepository;
  17004. if ($additionalFixedRepositories instanceof CompositeRepository) {
  17005. $additionalFixedRepositories = $additionalFixedRepositories->getRepositories();
  17006. } else {
  17007. $additionalFixedRepositories = array($additionalFixedRepositories);
  17008. }
  17009. foreach ($additionalFixedRepositories as $additionalFixedRepository) {
  17010. if ($additionalFixedRepository instanceof InstalledRepository || $additionalFixedRepository instanceof InstalledRepositoryInterface) {
  17011. $repositorySet->allowInstalledRepositories();
  17012. break;
  17013. }
  17014. }
  17015. $repositorySet->addRepository($this->additionalFixedRepository);
  17016. }
  17017. return $repositorySet;
  17018. }
  17019. private function createPolicy($forUpdate)
  17020. {
  17021. $preferStable = null;
  17022. $preferLowest = null;
  17023. if (!$forUpdate) {
  17024. $preferStable = $this->locker->getPreferStable();
  17025. $preferLowest = $this->locker->getPreferLowest();
  17026. }
  17027. if (null === $preferStable) {
  17028. $preferStable = $this->preferStable || $this->package->getPreferStable();
  17029. }
  17030. if (null === $preferLowest) {
  17031. $preferLowest = $this->preferLowest;
  17032. }
  17033. return new DefaultPolicy($preferStable, $preferLowest);
  17034. }
  17035. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, LockArrayRepository $lockedRepository = null)
  17036. {
  17037. $request = new Request($lockedRepository);
  17038. $request->fixPackage($rootPackage);
  17039. if ($rootPackage instanceof RootAliasPackage) {
  17040. $request->fixPackage($rootPackage->getAliasOf());
  17041. }
  17042. $fixedPackages = $platformRepo->getPackages();
  17043. if ($this->additionalFixedRepository) {
  17044. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  17045. }
  17046. $provided = $rootPackage->getProvides();
  17047. foreach ($fixedPackages as $package) {
  17048. if ($package->getRepository() !== $platformRepo
  17049. || !isset($provided[$package->getName()])
  17050. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  17051. ) {
  17052. $request->fixPackage($package);
  17053. }
  17054. }
  17055. return $request;
  17056. }
  17057. private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, $includeDevRequires = true)
  17058. {
  17059. if ($this->updateMirrors) {
  17060. $excludedPackages = array();
  17061. if (!$includeDevRequires) {
  17062. $excludedPackages = array_flip($this->locker->getDevPackageNames());
  17063. }
  17064. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  17065. if (!$lockedPackage instanceof AliasPackage && !isset($excludedPackages[$lockedPackage->getName()])) {
  17066. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  17067. }
  17068. }
  17069. } else {
  17070. $links = $this->package->getRequires();
  17071. if ($includeDevRequires) {
  17072. $links = array_merge($links, $this->package->getDevRequires());
  17073. }
  17074. foreach ($links as $link) {
  17075. $request->requireName($link->getTarget(), $link->getConstraint());
  17076. }
  17077. }
  17078. }
  17079. private function getRootAliases($forUpdate)
  17080. {
  17081. if ($forUpdate) {
  17082. $aliases = $this->package->getAliases();
  17083. } else {
  17084. $aliases = $this->locker->getAliases();
  17085. }
  17086. return $aliases;
  17087. }
  17088. private function extractPlatformRequirements(array $links)
  17089. {
  17090. $platformReqs = array();
  17091. foreach ($links as $link) {
  17092. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  17093. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  17094. }
  17095. }
  17096. return $platformReqs;
  17097. }
  17098. private function mockLocalRepositories(RepositoryManager $rm)
  17099. {
  17100. $packages = array();
  17101. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  17102. $packages[(string) $package] = clone $package;
  17103. }
  17104. foreach ($packages as $key => $package) {
  17105. if ($package instanceof AliasPackage) {
  17106. $alias = (string) $package->getAliasOf();
  17107. $className = get_class($package);
  17108. $packages[$key] = new $className($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  17109. }
  17110. }
  17111. $rm->setLocalRepository(
  17112. new InstalledArrayRepository($packages)
  17113. );
  17114. }
  17115. public static function create(IOInterface $io, Composer $composer)
  17116. {
  17117. return new static(
  17118. $io,
  17119. $composer->getConfig(),
  17120. $composer->getPackage(),
  17121. $composer->getDownloadManager(),
  17122. $composer->getRepositoryManager(),
  17123. $composer->getLocker(),
  17124. $composer->getInstallationManager(),
  17125. $composer->getEventDispatcher(),
  17126. $composer->getAutoloadGenerator()
  17127. );
  17128. }
  17129. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository)
  17130. {
  17131. $this->additionalFixedRepository = $additionalFixedRepository;
  17132. return $this;
  17133. }
  17134. public function setDryRun($dryRun = true)
  17135. {
  17136. $this->dryRun = (bool) $dryRun;
  17137. return $this;
  17138. }
  17139. public function isDryRun()
  17140. {
  17141. return $this->dryRun;
  17142. }
  17143. public function setPreferSource($preferSource = true)
  17144. {
  17145. $this->preferSource = (bool) $preferSource;
  17146. return $this;
  17147. }
  17148. public function setPreferDist($preferDist = true)
  17149. {
  17150. $this->preferDist = (bool) $preferDist;
  17151. return $this;
  17152. }
  17153. public function setOptimizeAutoloader($optimizeAutoloader)
  17154. {
  17155. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  17156. if (!$this->optimizeAutoloader) {
  17157. $this->setClassMapAuthoritative(false);
  17158. }
  17159. return $this;
  17160. }
  17161. public function setClassMapAuthoritative($classMapAuthoritative)
  17162. {
  17163. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  17164. if ($this->classMapAuthoritative) {
  17165. $this->setOptimizeAutoloader(true);
  17166. }
  17167. return $this;
  17168. }
  17169. public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null)
  17170. {
  17171. $this->apcuAutoloader = $apcuAutoloader;
  17172. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  17173. return $this;
  17174. }
  17175. public function setUpdate($update)
  17176. {
  17177. $this->update = (bool) $update;
  17178. return $this;
  17179. }
  17180. public function setInstall($install)
  17181. {
  17182. $this->install = (bool) $install;
  17183. return $this;
  17184. }
  17185. public function setDevMode($devMode = true)
  17186. {
  17187. $this->devMode = (bool) $devMode;
  17188. return $this;
  17189. }
  17190. public function setDumpAutoloader($dumpAutoloader = true)
  17191. {
  17192. $this->dumpAutoloader = (bool) $dumpAutoloader;
  17193. return $this;
  17194. }
  17195. public function setRunScripts($runScripts = true)
  17196. {
  17197. $this->runScripts = (bool) $runScripts;
  17198. return $this;
  17199. }
  17200. public function setConfig(Config $config)
  17201. {
  17202. $this->config = $config;
  17203. return $this;
  17204. }
  17205. public function setVerbose($verbose = true)
  17206. {
  17207. $this->verbose = (bool) $verbose;
  17208. return $this;
  17209. }
  17210. public function isVerbose()
  17211. {
  17212. return $this->verbose;
  17213. }
  17214. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  17215. {
  17216. if (is_array($ignorePlatformReqs)) {
  17217. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  17218. return PlatformRepository::isPlatformPackage($req);
  17219. });
  17220. } else {
  17221. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  17222. }
  17223. return $this;
  17224. }
  17225. public function setUpdateMirrors($updateMirrors)
  17226. {
  17227. $this->updateMirrors = $updateMirrors;
  17228. return $this;
  17229. }
  17230. public function setUpdateAllowList(array $packages)
  17231. {
  17232. $this->updateAllowList = array_flip(array_map('strtolower', $packages));
  17233. return $this;
  17234. }
  17235. public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  17236. {
  17237. 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)) {
  17238. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  17239. }
  17240. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  17241. return $this;
  17242. }
  17243. public function setPreferStable($preferStable = true)
  17244. {
  17245. $this->preferStable = (bool) $preferStable;
  17246. return $this;
  17247. }
  17248. public function setPreferLowest($preferLowest = true)
  17249. {
  17250. $this->preferLowest = (bool) $preferLowest;
  17251. return $this;
  17252. }
  17253. public function setWriteLock($writeLock = true)
  17254. {
  17255. $this->writeLock = (bool) $writeLock;
  17256. return $this;
  17257. }
  17258. public function setExecuteOperations($executeOperations = true)
  17259. {
  17260. $this->executeOperations = (bool) $executeOperations;
  17261. return $this;
  17262. }
  17263. public function disablePlugins()
  17264. {
  17265. $this->installationManager->disablePlugins();
  17266. return $this;
  17267. }
  17268. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter)
  17269. {
  17270. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  17271. return $this;
  17272. }
  17273. }
  17274. <?php
  17275. namespace Composer\Installer;
  17276. use Composer\IO\IOInterface;
  17277. use Composer\Package\PackageInterface;
  17278. use Composer\Util\Filesystem;
  17279. use Composer\Util\Platform;
  17280. use Composer\Util\ProcessExecutor;
  17281. use Composer\Util\Silencer;
  17282. class BinaryInstaller
  17283. {
  17284. protected $binDir;
  17285. protected $binCompat;
  17286. protected $io;
  17287. protected $filesystem;
  17288. public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null)
  17289. {
  17290. $this->binDir = $binDir;
  17291. $this->binCompat = $binCompat;
  17292. $this->io = $io;
  17293. $this->filesystem = $filesystem ?: new Filesystem();
  17294. }
  17295. public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
  17296. {
  17297. $binaries = $this->getBinaries($package);
  17298. if (!$binaries) {
  17299. return;
  17300. }
  17301. Platform::workaroundFilesystemIssues();
  17302. foreach ($binaries as $bin) {
  17303. $binPath = $installPath.'/'.$bin;
  17304. if (!file_exists($binPath)) {
  17305. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  17306. continue;
  17307. }
  17308. $binPath = realpath($binPath);
  17309. $this->initializeBinDir();
  17310. $link = $this->binDir.'/'.basename($bin);
  17311. if (file_exists($link)) {
  17312. if (is_link($link)) {
  17313. Silencer::call('chmod', $link, 0777 & ~umask());
  17314. }
  17315. if ($warnOnOverwrite) {
  17316. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  17317. }
  17318. continue;
  17319. }
  17320. if ($this->binCompat === "auto") {
  17321. if (Platform::isWindows() || Platform::isWindowsSubsystemForLinux()) {
  17322. $this->installFullBinaries($binPath, $link, $bin, $package);
  17323. } else {
  17324. $this->installSymlinkBinaries($binPath, $link);
  17325. }
  17326. } elseif ($this->binCompat === "full") {
  17327. $this->installFullBinaries($binPath, $link, $bin, $package);
  17328. } elseif ($this->binCompat === "symlink") {
  17329. $this->installSymlinkBinaries($binPath, $link);
  17330. }
  17331. Silencer::call('chmod', $binPath, 0777 & ~umask());
  17332. }
  17333. }
  17334. public function removeBinaries(PackageInterface $package)
  17335. {
  17336. $this->initializeBinDir();
  17337. $binaries = $this->getBinaries($package);
  17338. if (!$binaries) {
  17339. return;
  17340. }
  17341. foreach ($binaries as $bin) {
  17342. $link = $this->binDir.'/'.basename($bin);
  17343. if (is_link($link) || file_exists($link)) {
  17344. $this->filesystem->unlink($link);
  17345. }
  17346. if (file_exists($link.'.bat')) {
  17347. $this->filesystem->unlink($link.'.bat');
  17348. }
  17349. }
  17350. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  17351. Silencer::call('rmdir', $this->binDir);
  17352. }
  17353. }
  17354. public static function determineBinaryCaller($bin)
  17355. {
  17356. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  17357. return 'call';
  17358. }
  17359. $handle = fopen($bin, 'r');
  17360. $line = fgets($handle);
  17361. fclose($handle);
  17362. if (preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  17363. return trim($match[1]);
  17364. }
  17365. return 'php';
  17366. }
  17367. protected function getBinaries(PackageInterface $package)
  17368. {
  17369. return $package->getBinaries();
  17370. }
  17371. protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
  17372. {
  17373. if ('.bat' !== substr($binPath, -4)) {
  17374. $this->installUnixyProxyBinaries($binPath, $link);
  17375. $link .= '.bat';
  17376. if (file_exists($link)) {
  17377. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  17378. }
  17379. }
  17380. if (!file_exists($link)) {
  17381. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  17382. Silencer::call('chmod', $link, 0777 & ~umask());
  17383. }
  17384. }
  17385. protected function installSymlinkBinaries($binPath, $link)
  17386. {
  17387. if (!$this->filesystem->relativeSymlink($binPath, $link)) {
  17388. $this->installUnixyProxyBinaries($binPath, $link);
  17389. }
  17390. }
  17391. protected function installUnixyProxyBinaries($binPath, $link)
  17392. {
  17393. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  17394. Silencer::call('chmod', $link, 0777 & ~umask());
  17395. }
  17396. protected function initializeBinDir()
  17397. {
  17398. $this->filesystem->ensureDirectoryExists($this->binDir);
  17399. $this->binDir = realpath($this->binDir);
  17400. }
  17401. protected function generateWindowsProxyCode($bin, $link)
  17402. {
  17403. $binPath = $this->filesystem->findShortestPath($link, $bin);
  17404. $caller = self::determineBinaryCaller($bin);
  17405. return "@ECHO OFF\r\n".
  17406. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  17407. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  17408. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  17409. }
  17410. protected function generateUnixyProxyCode($bin, $link)
  17411. {
  17412. $binPath = $this->filesystem->findShortestPath($link, $bin);
  17413. $binDir = ProcessExecutor::escape(dirname($binPath));
  17414. $binFile = basename($binPath);
  17415. $binContents = file_get_contents($bin);
  17416. if (preg_match('{^(#!.*\r?\n)?<\?php}', $binContents, $match)) {
  17417. $proxyCode = empty($match[1]) ? '#!/usr/bin/env php' : trim($match[1]);
  17418. $binPathExported = var_export($binPath, true);
  17419. return $proxyCode . "\n" . <<<PROXY
  17420. <?php
  17421. /**
  17422. * Proxy PHP file generated by Composer
  17423. *
  17424. * This file includes the referenced bin path ($binPath) using ob_start to remove the shebang if present
  17425. * to prevent the shebang from being output on PHP<8
  17426. *
  17427. * @generated
  17428. */
  17429. namespace Composer;
  17430. \$binPath = __DIR__ . "/" . $binPathExported;
  17431. if (PHP_VERSION_ID < 80000) {
  17432. if (!class_exists('Composer\BinProxyWrapper')) {
  17433. /**
  17434. * @internal
  17435. */
  17436. final class BinProxyWrapper
  17437. {
  17438. private \$handle;
  17439. private \$position;
  17440. public function stream_open(\$path, \$mode, \$options, &\$opened_path)
  17441. {
  17442. // get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution
  17443. \$opened_path = substr(\$path, 21);
  17444. \$opened_path = realpath(\$opened_path) ?: \$opened_path;
  17445. \$this->handle = fopen(\$opened_path, \$mode);
  17446. \$this->position = 0;
  17447. // remove all traces of this stream wrapper once it has been used
  17448. stream_wrapper_unregister('composer-bin-proxy');
  17449. return (bool) \$this->handle;
  17450. }
  17451. public function stream_read(\$count)
  17452. {
  17453. \$data = fread(\$this->handle, \$count);
  17454. if (\$this->position === 0) {
  17455. \$data = preg_replace('{^#!.*\\r?\\n}', '', \$data);
  17456. }
  17457. \$this->position += strlen(\$data);
  17458. return \$data;
  17459. }
  17460. public function stream_cast(\$castAs)
  17461. {
  17462. return \$this->handle;
  17463. }
  17464. public function stream_close()
  17465. {
  17466. fclose(\$this->handle);
  17467. }
  17468. public function stream_lock(\$operation)
  17469. {
  17470. return \$operation ? flock(\$this->handle, \$operation) : true;
  17471. }
  17472. public function stream_tell()
  17473. {
  17474. return \$this->position;
  17475. }
  17476. public function stream_eof()
  17477. {
  17478. return feof(\$this->handle);
  17479. }
  17480. public function stream_stat()
  17481. {
  17482. return fstat(\$this->handle);
  17483. }
  17484. public function stream_set_option(\$option, \$arg1, \$arg2)
  17485. {
  17486. return true;
  17487. }
  17488. }
  17489. }
  17490. if (function_exists('stream_wrapper_register') && stream_wrapper_register('composer-bin-proxy', 'Composer\BinProxyWrapper')) {
  17491. include("composer-bin-proxy://" . \$binPath);
  17492. exit(0);
  17493. }
  17494. }
  17495. include \$binPath;
  17496. PROXY;
  17497. }
  17498. return <<<PROXY
  17499. #!/usr/bin/env sh
  17500. dir=\$(cd "\${0%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  17501. if [ -d /proc/cygdrive ]; then
  17502. case \$(which php) in
  17503. \$(readlink -n /proc/cygdrive)/*)
  17504. # We are in Cygwin using Windows php, so the path must be translated
  17505. dir=\$(cygpath -m "\$dir");
  17506. ;;
  17507. esac
  17508. fi
  17509. "\${dir}/$binFile" "\$@"
  17510. PROXY;
  17511. }
  17512. }
  17513. <?php
  17514. namespace Composer\Installer;
  17515. use Composer\Package\PackageInterface;
  17516. interface BinaryPresenceInterface
  17517. {
  17518. public function ensureBinariesPresence(PackageInterface $package);
  17519. }
  17520. <?php
  17521. namespace Composer\Installer;
  17522. use Composer\IO\IOInterface;
  17523. use Composer\IO\ConsoleIO;
  17524. use Composer\Package\PackageInterface;
  17525. use Composer\Package\AliasPackage;
  17526. use Composer\Repository\InstalledRepositoryInterface;
  17527. use Composer\DependencyResolver\Operation\OperationInterface;
  17528. use Composer\DependencyResolver\Operation\InstallOperation;
  17529. use Composer\DependencyResolver\Operation\UpdateOperation;
  17530. use Composer\DependencyResolver\Operation\UninstallOperation;
  17531. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  17532. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  17533. use Composer\Downloader\FileDownloader;
  17534. use Composer\EventDispatcher\EventDispatcher;
  17535. use Composer\Util\Loop;
  17536. use Composer\Util\Platform;
  17537. use React\Promise\PromiseInterface;
  17538. class InstallationManager
  17539. {
  17540. private $installers = array();
  17541. private $cache = array();
  17542. private $notifiablePackages = array();
  17543. private $loop;
  17544. private $io;
  17545. private $eventDispatcher;
  17546. private $outputProgress;
  17547. public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  17548. {
  17549. $this->loop = $loop;
  17550. $this->io = $io;
  17551. $this->eventDispatcher = $eventDispatcher;
  17552. }
  17553. public function reset()
  17554. {
  17555. $this->notifiablePackages = array();
  17556. FileDownloader::$downloadMetadata = array();
  17557. }
  17558. public function addInstaller(InstallerInterface $installer)
  17559. {
  17560. array_unshift($this->installers, $installer);
  17561. $this->cache = array();
  17562. }
  17563. public function removeInstaller(InstallerInterface $installer)
  17564. {
  17565. if (false !== ($key = array_search($installer, $this->installers, true))) {
  17566. array_splice($this->installers, $key, 1);
  17567. $this->cache = array();
  17568. }
  17569. }
  17570. public function disablePlugins()
  17571. {
  17572. foreach ($this->installers as $i => $installer) {
  17573. if (!$installer instanceof PluginInstaller) {
  17574. continue;
  17575. }
  17576. unset($this->installers[$i]);
  17577. }
  17578. }
  17579. public function getInstaller($type)
  17580. {
  17581. $type = strtolower($type);
  17582. if (isset($this->cache[$type])) {
  17583. return $this->cache[$type];
  17584. }
  17585. foreach ($this->installers as $installer) {
  17586. if ($installer->supports($type)) {
  17587. return $this->cache[$type] = $installer;
  17588. }
  17589. }
  17590. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  17591. }
  17592. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17593. {
  17594. if ($package instanceof AliasPackage) {
  17595. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  17596. }
  17597. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  17598. }
  17599. public function ensureBinariesPresence(PackageInterface $package)
  17600. {
  17601. try {
  17602. $installer = $this->getInstaller($package->getType());
  17603. } catch (\InvalidArgumentException $e) {
  17604. return;
  17605. }
  17606. if ($installer instanceof BinaryPresenceInterface) {
  17607. $installer->ensureBinariesPresence($package);
  17608. }
  17609. }
  17610. public function execute(InstalledRepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
  17611. {
  17612. $cleanupPromises = array();
  17613. $loop = $this->loop;
  17614. $io = $this->io;
  17615. $runCleanup = function () use (&$cleanupPromises, $loop) {
  17616. $promises = array();
  17617. $loop->abortJobs();
  17618. foreach ($cleanupPromises as $cleanup) {
  17619. $promises[] = new \React\Promise\Promise(function ($resolve, $reject) use ($cleanup) {
  17620. $promise = $cleanup();
  17621. if (!$promise instanceof PromiseInterface) {
  17622. $resolve();
  17623. } else {
  17624. $promise->then(function () use ($resolve) {
  17625. $resolve();
  17626. });
  17627. }
  17628. });
  17629. }
  17630. if (!empty($promises)) {
  17631. $loop->wait($promises);
  17632. }
  17633. };
  17634. $handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal');
  17635. $handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli';
  17636. $prevHandler = null;
  17637. $windowsHandler = null;
  17638. if ($handleInterruptsUnix) {
  17639. pcntl_async_signals(true);
  17640. $prevHandler = pcntl_signal_get_handler(SIGINT);
  17641. pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler, $io) {
  17642. $io->writeError('Received SIGINT, aborting', true, IOInterface::DEBUG);
  17643. $runCleanup();
  17644. if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {
  17645. call_user_func($prevHandler, $sig);
  17646. }
  17647. exit(130);
  17648. });
  17649. }
  17650. if ($handleInterruptsWindows) {
  17651. $windowsHandler = function ($event) use ($runCleanup, $io) {
  17652. if ($event !== PHP_WINDOWS_EVENT_CTRL_C) {
  17653. return;
  17654. }
  17655. $io->writeError('Received CTRL+C, aborting', true, IOInterface::DEBUG);
  17656. $runCleanup();
  17657. exit(130);
  17658. };
  17659. sapi_windows_set_ctrl_handler($windowsHandler);
  17660. }
  17661. try {
  17662. $batches = array();
  17663. $batch = array();
  17664. foreach ($operations as $index => $operation) {
  17665. if ($operation instanceof UpdateOperation || $operation instanceof InstallOperation) {
  17666. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  17667. if ($package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
  17668. if ($batch) {
  17669. $batches[] = $batch;
  17670. }
  17671. $batches[] = array($index => $operation);
  17672. $batch = array();
  17673. continue;
  17674. }
  17675. }
  17676. $batch[$index] = $operation;
  17677. }
  17678. if ($batch) {
  17679. $batches[] = $batch;
  17680. }
  17681. foreach ($batches as $batch) {
  17682. $this->downloadAndExecuteBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $operations);
  17683. }
  17684. } catch (\Exception $e) {
  17685. $runCleanup();
  17686. if ($handleInterruptsUnix) {
  17687. pcntl_signal(SIGINT, $prevHandler);
  17688. }
  17689. if ($handleInterruptsWindows) {
  17690. sapi_windows_set_ctrl_handler($windowsHandler, false);
  17691. }
  17692. throw $e;
  17693. }
  17694. if ($handleInterruptsUnix) {
  17695. pcntl_signal(SIGINT, $prevHandler);
  17696. }
  17697. if ($handleInterruptsWindows) {
  17698. sapi_windows_set_ctrl_handler($windowsHandler, false);
  17699. }
  17700. $repo->write($devMode, $this);
  17701. }
  17702. private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations)
  17703. {
  17704. $promises = array();
  17705. foreach ($operations as $index => $operation) {
  17706. $opType = $operation->getOperationType();
  17707. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  17708. continue;
  17709. }
  17710. if ($opType === 'update') {
  17711. $package = $operation->getTargetPackage();
  17712. $initialPackage = $operation->getInitialPackage();
  17713. } else {
  17714. $package = $operation->getPackage();
  17715. $initialPackage = null;
  17716. }
  17717. $installer = $this->getInstaller($package->getType());
  17718. $cleanupPromises[$index] = function () use ($opType, $installer, $package, $initialPackage) {
  17719. if (!$package->getInstallationSource()) {
  17720. return;
  17721. }
  17722. return $installer->cleanup($opType, $package, $initialPackage);
  17723. };
  17724. if ($opType !== 'uninstall') {
  17725. $promise = $installer->download($package, $initialPackage);
  17726. if ($promise) {
  17727. $promises[] = $promise;
  17728. }
  17729. }
  17730. }
  17731. if (count($promises)) {
  17732. $this->waitOnPromises($promises);
  17733. }
  17734. $batches = array();
  17735. $batch = array();
  17736. foreach ($operations as $index => $operation) {
  17737. if ($operation instanceof InstallOperation || $operation instanceof UpdateOperation) {
  17738. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  17739. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  17740. if ($batch) {
  17741. $batches[] = $batch;
  17742. }
  17743. $batches[] = array($index => $operation);
  17744. $batch = array();
  17745. continue;
  17746. }
  17747. }
  17748. $batch[$index] = $operation;
  17749. }
  17750. if ($batch) {
  17751. $batches[] = $batch;
  17752. }
  17753. foreach ($batches as $batch) {
  17754. $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $allOperations);
  17755. }
  17756. }
  17757. private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
  17758. {
  17759. $promises = array();
  17760. $postExecCallbacks = array();
  17761. foreach ($operations as $index => $operation) {
  17762. $opType = $operation->getOperationType();
  17763. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  17764. if ($this->io->isDebug()) {
  17765. $this->io->writeError(' - ' . $operation->show(false));
  17766. }
  17767. $this->$opType($repo, $operation);
  17768. continue;
  17769. }
  17770. if ($opType === 'update') {
  17771. $package = $operation->getTargetPackage();
  17772. $initialPackage = $operation->getInitialPackage();
  17773. } else {
  17774. $package = $operation->getPackage();
  17775. $initialPackage = null;
  17776. }
  17777. $installer = $this->getInstaller($package->getType());
  17778. $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
  17779. if (defined($event) && $runScripts && $this->eventDispatcher) {
  17780. $this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  17781. }
  17782. $dispatcher = $this->eventDispatcher;
  17783. $installManager = $this;
  17784. $io = $this->io;
  17785. $promise = $installer->prepare($opType, $package, $initialPackage);
  17786. if (!$promise instanceof PromiseInterface) {
  17787. $promise = \React\Promise\resolve();
  17788. }
  17789. $promise = $promise->then(function () use ($opType, $installManager, $repo, $operation) {
  17790. return $installManager->$opType($repo, $operation);
  17791. })->then($cleanupPromises[$index])
  17792. ->then(function () use ($installManager, $devMode, $repo) {
  17793. $repo->write($devMode, $installManager);
  17794. }, function ($e) use ($opType, $package, $io) {
  17795. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  17796. throw $e;
  17797. });
  17798. $postExecCallbacks[] = function () use ($opType, $runScripts, $dispatcher, $devMode, $repo, $allOperations, $operation) {
  17799. $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
  17800. if (defined($event) && $runScripts && $dispatcher) {
  17801. $dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  17802. }
  17803. };
  17804. $promises[] = $promise;
  17805. }
  17806. if (count($promises)) {
  17807. $this->waitOnPromises($promises);
  17808. }
  17809. Platform::workaroundFilesystemIssues();
  17810. foreach ($postExecCallbacks as $cb) {
  17811. $cb();
  17812. }
  17813. }
  17814. private function waitOnPromises(array $promises)
  17815. {
  17816. $progress = null;
  17817. if (
  17818. $this->outputProgress
  17819. && $this->io instanceof ConsoleIO
  17820. && !getenv('CI')
  17821. && !$this->io->isDebug()
  17822. && count($promises) > 1
  17823. ) {
  17824. $progress = $this->io->getProgressBar();
  17825. }
  17826. $this->loop->wait($promises, $progress);
  17827. if ($progress) {
  17828. $progress->clear();
  17829. if (!$this->io->isDecorated()) {
  17830. $this->io->writeError('');
  17831. }
  17832. }
  17833. }
  17834. public function install(InstalledRepositoryInterface $repo, InstallOperation $operation)
  17835. {
  17836. $package = $operation->getPackage();
  17837. $installer = $this->getInstaller($package->getType());
  17838. $promise = $installer->install($repo, $package);
  17839. $this->markForNotification($package);
  17840. return $promise;
  17841. }
  17842. public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation)
  17843. {
  17844. $initial = $operation->getInitialPackage();
  17845. $target = $operation->getTargetPackage();
  17846. $initialType = $initial->getType();
  17847. $targetType = $target->getType();
  17848. if ($initialType === $targetType) {
  17849. $installer = $this->getInstaller($initialType);
  17850. $promise = $installer->update($repo, $initial, $target);
  17851. $this->markForNotification($target);
  17852. } else {
  17853. $promise = $this->getInstaller($initialType)->uninstall($repo, $initial);
  17854. if (!$promise instanceof PromiseInterface) {
  17855. $promise = \React\Promise\resolve();
  17856. }
  17857. $installer = $this->getInstaller($targetType);
  17858. $promise = $promise->then(function () use ($installer, $repo, $target) {
  17859. return $installer->install($repo, $target);
  17860. });
  17861. }
  17862. return $promise;
  17863. }
  17864. public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation)
  17865. {
  17866. $package = $operation->getPackage();
  17867. $installer = $this->getInstaller($package->getType());
  17868. return $installer->uninstall($repo, $package);
  17869. }
  17870. public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation)
  17871. {
  17872. $package = $operation->getPackage();
  17873. if (!$repo->hasPackage($package)) {
  17874. $repo->addPackage(clone $package);
  17875. }
  17876. }
  17877. public function markAliasUninstalled(InstalledRepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
  17878. {
  17879. $package = $operation->getPackage();
  17880. $repo->removePackage($package);
  17881. }
  17882. public function getInstallPath(PackageInterface $package)
  17883. {
  17884. $installer = $this->getInstaller($package->getType());
  17885. return $installer->getInstallPath($package);
  17886. }
  17887. public function setOutputProgress($outputProgress)
  17888. {
  17889. $this->outputProgress = $outputProgress;
  17890. }
  17891. public function notifyInstalls(IOInterface $io)
  17892. {
  17893. $promises = array();
  17894. try {
  17895. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  17896. if (strpos($repoUrl, '%package%')) {
  17897. foreach ($packages as $package) {
  17898. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  17899. $params = array(
  17900. 'version' => $package->getPrettyVersion(),
  17901. 'version_normalized' => $package->getVersion(),
  17902. );
  17903. $opts = array(
  17904. 'retry-auth-failure' => false,
  17905. 'http' => array(
  17906. 'method' => 'POST',
  17907. 'header' => array('Content-type: application/x-www-form-urlencoded'),
  17908. 'content' => http_build_query($params, '', '&'),
  17909. 'timeout' => 3,
  17910. ),
  17911. );
  17912. $promises[] = $this->loop->getHttpDownloader()->add($url, $opts);
  17913. }
  17914. continue;
  17915. }
  17916. $postData = array('downloads' => array());
  17917. foreach ($packages as $package) {
  17918. $packageNotification = array(
  17919. 'name' => $package->getPrettyName(),
  17920. 'version' => $package->getVersion(),
  17921. );
  17922. if (strpos($repoUrl, 'packagist.org/') !== false) {
  17923. if (isset(FileDownloader::$downloadMetadata[$package->getName()])) {
  17924. $packageNotification['downloaded'] = FileDownloader::$downloadMetadata[$package->getName()];
  17925. } else {
  17926. $packageNotification['downloaded'] = false;
  17927. }
  17928. }
  17929. $postData['downloads'][] = $packageNotification;
  17930. }
  17931. $opts = array(
  17932. 'retry-auth-failure' => false,
  17933. 'http' => array(
  17934. 'method' => 'POST',
  17935. 'header' => array('Content-Type: application/json'),
  17936. 'content' => json_encode($postData),
  17937. 'timeout' => 6,
  17938. ),
  17939. );
  17940. $promises[] = $this->loop->getHttpDownloader()->add($repoUrl, $opts);
  17941. }
  17942. $this->loop->wait($promises);
  17943. } catch (\Exception $e) {
  17944. }
  17945. $this->reset();
  17946. }
  17947. private function markForNotification(PackageInterface $package)
  17948. {
  17949. if ($package->getNotificationUrl()) {
  17950. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  17951. }
  17952. }
  17953. }
  17954. <?php
  17955. namespace Composer\Installer;
  17956. use Composer\Composer;
  17957. use Composer\DependencyResolver\Transaction;
  17958. use Composer\EventDispatcher\Event;
  17959. use Composer\IO\IOInterface;
  17960. class InstallerEvent extends Event
  17961. {
  17962. private $composer;
  17963. private $io;
  17964. private $devMode;
  17965. private $executeOperations;
  17966. private $transaction;
  17967. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, $executeOperations, Transaction $transaction)
  17968. {
  17969. parent::__construct($eventName);
  17970. $this->composer = $composer;
  17971. $this->io = $io;
  17972. $this->devMode = $devMode;
  17973. $this->executeOperations = $executeOperations;
  17974. $this->transaction = $transaction;
  17975. }
  17976. public function getComposer()
  17977. {
  17978. return $this->composer;
  17979. }
  17980. public function getIO()
  17981. {
  17982. return $this->io;
  17983. }
  17984. public function isDevMode()
  17985. {
  17986. return $this->devMode;
  17987. }
  17988. public function isExecutingOperations()
  17989. {
  17990. return $this->executeOperations;
  17991. }
  17992. public function getTransaction()
  17993. {
  17994. return $this->transaction;
  17995. }
  17996. }
  17997. <?php
  17998. namespace Composer\Installer;
  17999. class InstallerEvents
  18000. {
  18001. const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  18002. }
  18003. <?php
  18004. namespace Composer\Installer;
  18005. use Composer\Package\PackageInterface;
  18006. use Composer\Repository\InstalledRepositoryInterface;
  18007. use InvalidArgumentException;
  18008. use React\Promise\PromiseInterface;
  18009. interface InstallerInterface
  18010. {
  18011. public function supports($packageType);
  18012. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  18013. public function download(PackageInterface $package, PackageInterface $prevPackage = null);
  18014. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null);
  18015. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  18016. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  18017. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  18018. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null);
  18019. public function getInstallPath(PackageInterface $package);
  18020. }
  18021. <?php
  18022. namespace Composer\Installer;
  18023. use Composer\Composer;
  18024. use Composer\IO\IOInterface;
  18025. use Composer\Repository\InstalledRepositoryInterface;
  18026. use Composer\Package\PackageInterface;
  18027. use Composer\Util\Filesystem;
  18028. use Composer\Util\Silencer;
  18029. use Composer\Util\Platform;
  18030. use React\Promise\PromiseInterface;
  18031. use Composer\Downloader\DownloadManager;
  18032. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  18033. {
  18034. protected $composer;
  18035. protected $vendorDir;
  18036. protected $downloadManager;
  18037. protected $io;
  18038. protected $type;
  18039. protected $filesystem;
  18040. protected $binaryInstaller;
  18041. public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
  18042. {
  18043. $this->composer = $composer;
  18044. $this->downloadManager = $composer->getDownloadManager();
  18045. $this->io = $io;
  18046. $this->type = $type;
  18047. $this->filesystem = $filesystem ?: new Filesystem();
  18048. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  18049. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem);
  18050. }
  18051. public function supports($packageType)
  18052. {
  18053. return $packageType === $this->type || null === $this->type;
  18054. }
  18055. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  18056. {
  18057. if (!$repo->hasPackage($package)) {
  18058. return false;
  18059. }
  18060. $installPath = $this->getInstallPath($package);
  18061. if (Filesystem::isReadable($installPath)) {
  18062. return true;
  18063. }
  18064. return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
  18065. }
  18066. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  18067. {
  18068. $this->initializeVendorDir();
  18069. $downloadPath = $this->getInstallPath($package);
  18070. return $this->downloadManager->download($package, $downloadPath, $prevPackage);
  18071. }
  18072. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18073. {
  18074. $this->initializeVendorDir();
  18075. $downloadPath = $this->getInstallPath($package);
  18076. return $this->downloadManager->prepare($type, $package, $downloadPath, $prevPackage);
  18077. }
  18078. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18079. {
  18080. $this->initializeVendorDir();
  18081. $downloadPath = $this->getInstallPath($package);
  18082. return $this->downloadManager->cleanup($type, $package, $downloadPath, $prevPackage);
  18083. }
  18084. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  18085. {
  18086. $this->initializeVendorDir();
  18087. $downloadPath = $this->getInstallPath($package);
  18088. if (!Filesystem::isReadable($downloadPath) && $repo->hasPackage($package)) {
  18089. $this->binaryInstaller->removeBinaries($package);
  18090. }
  18091. $promise = $this->installCode($package);
  18092. if (!$promise instanceof PromiseInterface) {
  18093. $promise = \React\Promise\resolve();
  18094. }
  18095. $binaryInstaller = $this->binaryInstaller;
  18096. $installPath = $this->getInstallPath($package);
  18097. return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) {
  18098. $binaryInstaller->installBinaries($package, $installPath);
  18099. if (!$repo->hasPackage($package)) {
  18100. $repo->addPackage(clone $package);
  18101. }
  18102. });
  18103. }
  18104. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  18105. {
  18106. if (!$repo->hasPackage($initial)) {
  18107. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  18108. }
  18109. $this->initializeVendorDir();
  18110. $this->binaryInstaller->removeBinaries($initial);
  18111. $promise = $this->updateCode($initial, $target);
  18112. if (!$promise instanceof PromiseInterface) {
  18113. $promise = \React\Promise\resolve();
  18114. }
  18115. $binaryInstaller = $this->binaryInstaller;
  18116. $installPath = $this->getInstallPath($target);
  18117. return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) {
  18118. $binaryInstaller->installBinaries($target, $installPath);
  18119. $repo->removePackage($initial);
  18120. if (!$repo->hasPackage($target)) {
  18121. $repo->addPackage(clone $target);
  18122. }
  18123. });
  18124. }
  18125. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  18126. {
  18127. if (!$repo->hasPackage($package)) {
  18128. throw new \InvalidArgumentException('Package is not installed: '.$package);
  18129. }
  18130. $promise = $this->removeCode($package);
  18131. if (!$promise instanceof PromiseInterface) {
  18132. $promise = \React\Promise\resolve();
  18133. }
  18134. $binaryInstaller = $this->binaryInstaller;
  18135. $downloadPath = $this->getPackageBasePath($package);
  18136. $filesystem = $this->filesystem;
  18137. return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) {
  18138. $binaryInstaller->removeBinaries($package);
  18139. $repo->removePackage($package);
  18140. if (strpos($package->getName(), '/')) {
  18141. $packageVendorDir = dirname($downloadPath);
  18142. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  18143. Silencer::call('rmdir', $packageVendorDir);
  18144. }
  18145. }
  18146. });
  18147. }
  18148. public function getInstallPath(PackageInterface $package)
  18149. {
  18150. $this->initializeVendorDir();
  18151. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  18152. $targetDir = $package->getTargetDir();
  18153. return $basePath . ($targetDir ? '/'.$targetDir : '');
  18154. }
  18155. public function ensureBinariesPresence(PackageInterface $package)
  18156. {
  18157. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  18158. }
  18159. protected function getPackageBasePath(PackageInterface $package)
  18160. {
  18161. $installPath = $this->getInstallPath($package);
  18162. $targetDir = $package->getTargetDir();
  18163. if ($targetDir) {
  18164. return preg_replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  18165. }
  18166. return $installPath;
  18167. }
  18168. protected function installCode(PackageInterface $package)
  18169. {
  18170. $downloadPath = $this->getInstallPath($package);
  18171. return $this->downloadManager->install($package, $downloadPath);
  18172. }
  18173. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  18174. {
  18175. $initialDownloadPath = $this->getInstallPath($initial);
  18176. $targetDownloadPath = $this->getInstallPath($target);
  18177. if ($targetDownloadPath !== $initialDownloadPath) {
  18178. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  18179. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  18180. ) {
  18181. $promise = $this->removeCode($initial);
  18182. if (!$promise instanceof PromiseInterface) {
  18183. $promise = \React\Promise\resolve();
  18184. }
  18185. $self = $this;
  18186. return $promise->then(function () use ($self, $target) {
  18187. $reflMethod = new \ReflectionMethod($self, 'installCode');
  18188. $reflMethod->setAccessible(true);
  18189. return $reflMethod->invoke($self, $target);
  18190. });
  18191. }
  18192. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  18193. }
  18194. return $this->downloadManager->update($initial, $target, $targetDownloadPath);
  18195. }
  18196. protected function removeCode(PackageInterface $package)
  18197. {
  18198. $downloadPath = $this->getPackageBasePath($package);
  18199. return $this->downloadManager->remove($package, $downloadPath);
  18200. }
  18201. protected function initializeVendorDir()
  18202. {
  18203. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  18204. $this->vendorDir = realpath($this->vendorDir);
  18205. }
  18206. }
  18207. <?php
  18208. namespace Composer\Installer;
  18209. use Composer\Repository\InstalledRepositoryInterface;
  18210. use Composer\Package\PackageInterface;
  18211. use Composer\IO\IOInterface;
  18212. use Composer\DependencyResolver\Operation\UpdateOperation;
  18213. use Composer\DependencyResolver\Operation\InstallOperation;
  18214. use Composer\DependencyResolver\Operation\UninstallOperation;
  18215. class MetapackageInstaller implements InstallerInterface
  18216. {
  18217. private $io;
  18218. public function __construct(IOInterface $io)
  18219. {
  18220. $this->io = $io;
  18221. }
  18222. public function supports($packageType)
  18223. {
  18224. return $packageType === 'metapackage';
  18225. }
  18226. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  18227. {
  18228. return $repo->hasPackage($package);
  18229. }
  18230. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  18231. {
  18232. return \React\Promise\resolve();
  18233. }
  18234. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18235. {
  18236. return \React\Promise\resolve();
  18237. }
  18238. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18239. {
  18240. return \React\Promise\resolve();
  18241. }
  18242. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  18243. {
  18244. $this->io->writeError(" - " . InstallOperation::format($package));
  18245. $repo->addPackage(clone $package);
  18246. return \React\Promise\resolve();
  18247. }
  18248. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  18249. {
  18250. if (!$repo->hasPackage($initial)) {
  18251. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  18252. }
  18253. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  18254. $repo->removePackage($initial);
  18255. $repo->addPackage(clone $target);
  18256. return \React\Promise\resolve();
  18257. }
  18258. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  18259. {
  18260. if (!$repo->hasPackage($package)) {
  18261. throw new \InvalidArgumentException('Package is not installed: '.$package);
  18262. }
  18263. $this->io->writeError(" - " . UninstallOperation::format($package));
  18264. $repo->removePackage($package);
  18265. return \React\Promise\resolve();
  18266. }
  18267. public function getInstallPath(PackageInterface $package)
  18268. {
  18269. return '';
  18270. }
  18271. }
  18272. <?php
  18273. namespace Composer\Installer;
  18274. use Composer\Repository\InstalledRepositoryInterface;
  18275. use Composer\Package\PackageInterface;
  18276. class NoopInstaller implements InstallerInterface
  18277. {
  18278. public function supports($packageType)
  18279. {
  18280. return true;
  18281. }
  18282. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  18283. {
  18284. return $repo->hasPackage($package);
  18285. }
  18286. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  18287. {
  18288. return \React\Promise\resolve();
  18289. }
  18290. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18291. {
  18292. return \React\Promise\resolve();
  18293. }
  18294. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18295. {
  18296. return \React\Promise\resolve();
  18297. }
  18298. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  18299. {
  18300. if (!$repo->hasPackage($package)) {
  18301. $repo->addPackage(clone $package);
  18302. }
  18303. return \React\Promise\resolve();
  18304. }
  18305. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  18306. {
  18307. if (!$repo->hasPackage($initial)) {
  18308. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  18309. }
  18310. $repo->removePackage($initial);
  18311. if (!$repo->hasPackage($target)) {
  18312. $repo->addPackage(clone $target);
  18313. }
  18314. return \React\Promise\resolve();
  18315. }
  18316. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  18317. {
  18318. if (!$repo->hasPackage($package)) {
  18319. throw new \InvalidArgumentException('Package is not installed: '.$package);
  18320. }
  18321. $repo->removePackage($package);
  18322. return \React\Promise\resolve();
  18323. }
  18324. public function getInstallPath(PackageInterface $package)
  18325. {
  18326. $targetDir = $package->getTargetDir();
  18327. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  18328. }
  18329. }
  18330. <?php
  18331. namespace Composer\Installer;
  18332. use Composer\Composer;
  18333. use Composer\IO\IOInterface;
  18334. use Composer\DependencyResolver\Operation\OperationInterface;
  18335. use Composer\Repository\RepositoryInterface;
  18336. use Composer\EventDispatcher\Event;
  18337. class PackageEvent extends Event
  18338. {
  18339. private $composer;
  18340. private $io;
  18341. private $devMode;
  18342. private $localRepo;
  18343. private $operations;
  18344. private $operation;
  18345. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  18346. {
  18347. parent::__construct($eventName);
  18348. $this->composer = $composer;
  18349. $this->io = $io;
  18350. $this->devMode = $devMode;
  18351. $this->localRepo = $localRepo;
  18352. $this->operations = $operations;
  18353. $this->operation = $operation;
  18354. }
  18355. public function getComposer()
  18356. {
  18357. return $this->composer;
  18358. }
  18359. public function getIO()
  18360. {
  18361. return $this->io;
  18362. }
  18363. public function isDevMode()
  18364. {
  18365. return $this->devMode;
  18366. }
  18367. public function getLocalRepo()
  18368. {
  18369. return $this->localRepo;
  18370. }
  18371. public function getOperations()
  18372. {
  18373. return $this->operations;
  18374. }
  18375. public function getOperation()
  18376. {
  18377. return $this->operation;
  18378. }
  18379. }
  18380. <?php
  18381. namespace Composer\Installer;
  18382. class PackageEvents
  18383. {
  18384. const PRE_PACKAGE_INSTALL = 'pre-package-install';
  18385. const POST_PACKAGE_INSTALL = 'post-package-install';
  18386. const PRE_PACKAGE_UPDATE = 'pre-package-update';
  18387. const POST_PACKAGE_UPDATE = 'post-package-update';
  18388. const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  18389. const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  18390. }
  18391. <?php
  18392. namespace Composer\Installer;
  18393. use Composer\Composer;
  18394. use Composer\IO\IOInterface;
  18395. use Composer\Repository\InstalledRepositoryInterface;
  18396. use Composer\Package\PackageInterface;
  18397. use Composer\Util\Filesystem;
  18398. use Composer\Util\Platform;
  18399. use React\Promise\PromiseInterface;
  18400. class PluginInstaller extends LibraryInstaller
  18401. {
  18402. public function __construct(IOInterface $io, Composer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null)
  18403. {
  18404. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  18405. }
  18406. public function supports($packageType)
  18407. {
  18408. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  18409. }
  18410. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  18411. {
  18412. $extra = $package->getExtra();
  18413. if (empty($extra['class'])) {
  18414. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  18415. }
  18416. return parent::download($package, $prevPackage);
  18417. }
  18418. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  18419. {
  18420. $promise = parent::install($repo, $package);
  18421. if (!$promise instanceof PromiseInterface) {
  18422. $promise = \React\Promise\resolve();
  18423. }
  18424. $pluginManager = $this->composer->getPluginManager();
  18425. $self = $this;
  18426. return $promise->then(function () use ($self, $pluginManager, $package, $repo) {
  18427. try {
  18428. Platform::workaroundFilesystemIssues();
  18429. $pluginManager->registerPackage($package, true);
  18430. } catch (\Exception $e) {
  18431. $self->rollbackInstall($e, $repo, $package);
  18432. }
  18433. });
  18434. }
  18435. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  18436. {
  18437. $promise = parent::update($repo, $initial, $target);
  18438. if (!$promise instanceof PromiseInterface) {
  18439. $promise = \React\Promise\resolve();
  18440. }
  18441. $pluginManager = $this->composer->getPluginManager();
  18442. $self = $this;
  18443. return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) {
  18444. try {
  18445. Platform::workaroundFilesystemIssues();
  18446. $pluginManager->deactivatePackage($initial);
  18447. $pluginManager->registerPackage($target, true);
  18448. } catch (\Exception $e) {
  18449. $self->rollbackInstall($e, $repo, $target);
  18450. }
  18451. });
  18452. }
  18453. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  18454. {
  18455. $this->composer->getPluginManager()->uninstallPackage($package);
  18456. return parent::uninstall($repo, $package);
  18457. }
  18458. public function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package)
  18459. {
  18460. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  18461. parent::uninstall($repo, $package);
  18462. throw $e;
  18463. }
  18464. }
  18465. <?php
  18466. namespace Composer\Installer;
  18467. use Composer\Package\PackageInterface;
  18468. use Composer\Downloader\DownloadManager;
  18469. use Composer\Repository\InstalledRepositoryInterface;
  18470. use Composer\Util\Filesystem;
  18471. class ProjectInstaller implements InstallerInterface
  18472. {
  18473. private $installPath;
  18474. private $downloadManager;
  18475. private $filesystem;
  18476. public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
  18477. {
  18478. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  18479. $this->downloadManager = $dm;
  18480. $this->filesystem = $fs;
  18481. }
  18482. public function supports($packageType)
  18483. {
  18484. return true;
  18485. }
  18486. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  18487. {
  18488. return false;
  18489. }
  18490. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  18491. {
  18492. $installPath = $this->installPath;
  18493. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  18494. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  18495. }
  18496. if (!is_dir($installPath)) {
  18497. mkdir($installPath, 0777, true);
  18498. }
  18499. return $this->downloadManager->download($package, $installPath, $prevPackage);
  18500. }
  18501. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18502. {
  18503. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  18504. }
  18505. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18506. {
  18507. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  18508. }
  18509. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  18510. {
  18511. return $this->downloadManager->install($package, $this->installPath);
  18512. }
  18513. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  18514. {
  18515. throw new \InvalidArgumentException("not supported");
  18516. }
  18517. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  18518. {
  18519. throw new \InvalidArgumentException("not supported");
  18520. }
  18521. public function getInstallPath(PackageInterface $package)
  18522. {
  18523. return $this->installPath;
  18524. }
  18525. }
  18526. <?php
  18527. namespace Composer\Installer;
  18528. use Composer\IO\IOInterface;
  18529. use Composer\Package\PackageInterface;
  18530. use Composer\Repository\InstalledRepository;
  18531. use Symfony\Component\Console\Formatter\OutputFormatter;
  18532. class SuggestedPackagesReporter
  18533. {
  18534. const MODE_LIST = 1;
  18535. const MODE_BY_PACKAGE = 2;
  18536. const MODE_BY_SUGGESTION = 4;
  18537. protected $suggestedPackages = array();
  18538. private $io;
  18539. public function __construct(IOInterface $io)
  18540. {
  18541. $this->io = $io;
  18542. }
  18543. public function getPackages()
  18544. {
  18545. return $this->suggestedPackages;
  18546. }
  18547. public function addPackage($source, $target, $reason)
  18548. {
  18549. $this->suggestedPackages[] = array(
  18550. 'source' => $source,
  18551. 'target' => $target,
  18552. 'reason' => $reason,
  18553. );
  18554. return $this;
  18555. }
  18556. public function addSuggestionsFromPackage(PackageInterface $package)
  18557. {
  18558. $source = $package->getPrettyName();
  18559. foreach ($package->getSuggests() as $target => $reason) {
  18560. $this->addPackage(
  18561. $source,
  18562. $target,
  18563. $reason
  18564. );
  18565. }
  18566. return $this;
  18567. }
  18568. public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  18569. {
  18570. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  18571. $suggesters = array();
  18572. $suggested = array();
  18573. foreach ($suggestedPackages as $suggestion) {
  18574. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  18575. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  18576. }
  18577. ksort($suggesters);
  18578. ksort($suggested);
  18579. if ($mode & self::MODE_LIST) {
  18580. foreach (array_keys($suggested) as $name) {
  18581. $this->io->write(sprintf('<info>%s</info>', $name));
  18582. }
  18583. return;
  18584. }
  18585. if ($mode & self::MODE_BY_PACKAGE) {
  18586. foreach ($suggesters as $suggester => $suggestions) {
  18587. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  18588. foreach ($suggestions as $suggestion => $reason) {
  18589. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  18590. }
  18591. $this->io->write('');
  18592. }
  18593. }
  18594. if ($mode & self::MODE_BY_SUGGESTION) {
  18595. if ($mode & self::MODE_BY_PACKAGE) {
  18596. $this->io->write(str_repeat('-', 78));
  18597. }
  18598. foreach ($suggested as $suggestion => $suggesters) {
  18599. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  18600. foreach ($suggesters as $suggester => $reason) {
  18601. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  18602. }
  18603. $this->io->write('');
  18604. }
  18605. }
  18606. if ($onlyDependentsOf) {
  18607. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  18608. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  18609. if ($diff) {
  18610. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  18611. }
  18612. }
  18613. }
  18614. public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  18615. {
  18616. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  18617. if ($suggestedPackages) {
  18618. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  18619. }
  18620. }
  18621. private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  18622. {
  18623. $suggestedPackages = $this->getPackages();
  18624. $installedNames = array();
  18625. if (null !== $installedRepo && !empty($suggestedPackages)) {
  18626. foreach ($installedRepo->getPackages() as $package) {
  18627. $installedNames = array_merge(
  18628. $installedNames,
  18629. $package->getNames()
  18630. );
  18631. }
  18632. }
  18633. $sourceFilter = array();
  18634. if ($onlyDependentsOf) {
  18635. $sourceFilter = array_map(function ($link) {
  18636. return $link->getTarget();
  18637. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  18638. $sourceFilter[] = $onlyDependentsOf->getName();
  18639. }
  18640. $suggestions = array();
  18641. foreach ($suggestedPackages as $suggestion) {
  18642. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  18643. continue;
  18644. }
  18645. $suggestions[] = $suggestion;
  18646. }
  18647. return $suggestions;
  18648. }
  18649. private function escapeOutput($string)
  18650. {
  18651. return OutputFormatter::escape(
  18652. $this->removeControlCharacters($string)
  18653. );
  18654. }
  18655. private function removeControlCharacters($string)
  18656. {
  18657. return preg_replace(
  18658. '/[[:cntrl:]]/',
  18659. '',
  18660. str_replace("\n", ' ', $string)
  18661. );
  18662. }
  18663. }
  18664. <?php
  18665. namespace Composer\Json;
  18666. use JsonSchema\Validator;
  18667. use Seld\JsonLint\JsonParser;
  18668. use Seld\JsonLint\ParsingException;
  18669. use Composer\Util\HttpDownloader;
  18670. use Composer\IO\IOInterface;
  18671. use Composer\Downloader\TransportException;
  18672. class JsonFile
  18673. {
  18674. const LAX_SCHEMA = 1;
  18675. const STRICT_SCHEMA = 2;
  18676. const JSON_UNESCAPED_SLASHES = 64;
  18677. const JSON_PRETTY_PRINT = 128;
  18678. const JSON_UNESCAPED_UNICODE = 256;
  18679. const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
  18680. private $path;
  18681. private $httpDownloader;
  18682. private $io;
  18683. public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
  18684. {
  18685. $this->path = $path;
  18686. if (null === $httpDownloader && preg_match('{^https?://}i', $path)) {
  18687. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  18688. }
  18689. $this->httpDownloader = $httpDownloader;
  18690. $this->io = $io;
  18691. }
  18692. public function getPath()
  18693. {
  18694. return $this->path;
  18695. }
  18696. public function exists()
  18697. {
  18698. return is_file($this->path);
  18699. }
  18700. public function read()
  18701. {
  18702. try {
  18703. if ($this->httpDownloader) {
  18704. $json = $this->httpDownloader->get($this->path)->getBody();
  18705. } else {
  18706. if ($this->io && $this->io->isDebug()) {
  18707. $realpathInfo = '';
  18708. $realpath = realpath($this->path);
  18709. if (false !== $realpath && $realpath !== $this->path) {
  18710. $realpathInfo = ' (' . $realpath . ')';
  18711. }
  18712. $this->io->writeError('Reading ' . $this->path . $realpathInfo);
  18713. }
  18714. $json = file_get_contents($this->path);
  18715. }
  18716. } catch (TransportException $e) {
  18717. throw new \RuntimeException($e->getMessage(), 0, $e);
  18718. } catch (\Exception $e) {
  18719. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  18720. }
  18721. return static::parseJson($json, $this->path);
  18722. }
  18723. public function write(array $hash, $options = 448)
  18724. {
  18725. if ($this->path === 'php://memory') {
  18726. file_put_contents($this->path, static::encode($hash, $options));
  18727. return;
  18728. }
  18729. $dir = dirname($this->path);
  18730. if (!is_dir($dir)) {
  18731. if (file_exists($dir)) {
  18732. throw new \UnexpectedValueException(
  18733. realpath($dir).' exists and is not a directory.'
  18734. );
  18735. }
  18736. if (!@mkdir($dir, 0777, true)) {
  18737. throw new \UnexpectedValueException(
  18738. $dir.' does not exist and could not be created.'
  18739. );
  18740. }
  18741. }
  18742. $retries = 3;
  18743. while ($retries--) {
  18744. try {
  18745. $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
  18746. break;
  18747. } catch (\Exception $e) {
  18748. if ($retries) {
  18749. usleep(500000);
  18750. continue;
  18751. }
  18752. throw $e;
  18753. }
  18754. }
  18755. }
  18756. private function filePutContentsIfModified($path, $content)
  18757. {
  18758. $currentContent = @file_get_contents($path);
  18759. if (!$currentContent || ($currentContent != $content)) {
  18760. return file_put_contents($path, $content);
  18761. }
  18762. return 0;
  18763. }
  18764. public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = null)
  18765. {
  18766. $content = file_get_contents($this->path);
  18767. $data = json_decode($content);
  18768. if (null === $data && 'null' !== $content) {
  18769. self::validateSyntax($content, $this->path);
  18770. }
  18771. $isComposerSchemaFile = false;
  18772. if (null === $schemaFile) {
  18773. $isComposerSchemaFile = true;
  18774. $schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH;
  18775. }
  18776. if (false === strpos($schemaFile, '://')) {
  18777. $schemaFile = 'file://' . $schemaFile;
  18778. }
  18779. $schemaData = (object) array('$ref' => $schemaFile);
  18780. if ($schema === self::LAX_SCHEMA) {
  18781. $schemaData->additionalProperties = true;
  18782. $schemaData->required = array();
  18783. } elseif ($schema === self::STRICT_SCHEMA && $isComposerSchemaFile) {
  18784. $schemaData->additionalProperties = false;
  18785. $schemaData->required = array('name', 'description');
  18786. }
  18787. $validator = new Validator();
  18788. $validator->check($data, $schemaData);
  18789. if (!$validator->isValid()) {
  18790. $errors = array();
  18791. foreach ((array) $validator->getErrors() as $error) {
  18792. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  18793. }
  18794. throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
  18795. }
  18796. return true;
  18797. }
  18798. public static function encode($data, $options = 448)
  18799. {
  18800. if (PHP_VERSION_ID >= 50400) {
  18801. $json = json_encode($data, $options);
  18802. if (false === $json) {
  18803. self::throwEncodeError(json_last_error());
  18804. }
  18805. if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512) || (defined('JSON_C_VERSION') && version_compare(phpversion('json'), '1.3.6', '<'))) {
  18806. $json = preg_replace('/\[\s+\]/', '[]', $json);
  18807. $json = preg_replace('/\{\s+\}/', '{}', $json);
  18808. }
  18809. return $json;
  18810. }
  18811. $json = json_encode($data);
  18812. if (false === $json) {
  18813. self::throwEncodeError(json_last_error());
  18814. }
  18815. $prettyPrint = (bool) ($options & self::JSON_PRETTY_PRINT);
  18816. $unescapeUnicode = (bool) ($options & self::JSON_UNESCAPED_UNICODE);
  18817. $unescapeSlashes = (bool) ($options & self::JSON_UNESCAPED_SLASHES);
  18818. if (!$prettyPrint && !$unescapeUnicode && !$unescapeSlashes) {
  18819. return $json;
  18820. }
  18821. return JsonFormatter::format($json, $unescapeUnicode, $unescapeSlashes);
  18822. }
  18823. private static function throwEncodeError($code)
  18824. {
  18825. switch ($code) {
  18826. case JSON_ERROR_DEPTH:
  18827. $msg = 'Maximum stack depth exceeded';
  18828. break;
  18829. case JSON_ERROR_STATE_MISMATCH:
  18830. $msg = 'Underflow or the modes mismatch';
  18831. break;
  18832. case JSON_ERROR_CTRL_CHAR:
  18833. $msg = 'Unexpected control character found';
  18834. break;
  18835. case JSON_ERROR_UTF8:
  18836. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  18837. break;
  18838. default:
  18839. $msg = 'Unknown error';
  18840. }
  18841. throw new \RuntimeException('JSON encoding failed: '.$msg);
  18842. }
  18843. public static function parseJson($json, $file = null)
  18844. {
  18845. if (null === $json) {
  18846. return null;
  18847. }
  18848. $data = json_decode($json, true);
  18849. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  18850. self::validateSyntax($json, $file);
  18851. }
  18852. return $data;
  18853. }
  18854. protected static function validateSyntax($json, $file = null)
  18855. {
  18856. $parser = new JsonParser();
  18857. $result = $parser->lint($json);
  18858. if (null === $result) {
  18859. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  18860. throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
  18861. }
  18862. return true;
  18863. }
  18864. throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
  18865. }
  18866. }
  18867. <?php
  18868. namespace Composer\Json;
  18869. class JsonFormatter
  18870. {
  18871. public static function format($json, $unescapeUnicode, $unescapeSlashes)
  18872. {
  18873. $result = '';
  18874. $pos = 0;
  18875. $strLen = strlen($json);
  18876. $indentStr = ' ';
  18877. $newLine = "\n";
  18878. $outOfQuotes = true;
  18879. $buffer = '';
  18880. $noescape = true;
  18881. for ($i = 0; $i < $strLen; $i++) {
  18882. $char = substr($json, $i, 1);
  18883. if ('"' === $char && $noescape) {
  18884. $outOfQuotes = !$outOfQuotes;
  18885. }
  18886. if (!$outOfQuotes) {
  18887. $buffer .= $char;
  18888. $noescape = '\\' === $char ? !$noescape : true;
  18889. continue;
  18890. }
  18891. if ('' !== $buffer) {
  18892. if ($unescapeSlashes) {
  18893. $buffer = str_replace('\\/', '/', $buffer);
  18894. }
  18895. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  18896. $buffer = preg_replace_callback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
  18897. $l = strlen($match[1]);
  18898. if ($l % 2) {
  18899. $code = hexdec($match[2]);
  18900. if (0xD800 <= $code && 0xDFFF >= $code) {
  18901. return $match[0];
  18902. }
  18903. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  18904. pack('H*', $match[2]),
  18905. 'UTF-8',
  18906. 'UCS-2BE'
  18907. );
  18908. }
  18909. return $match[0];
  18910. }, $buffer);
  18911. }
  18912. $result .= $buffer.$char;
  18913. $buffer = '';
  18914. continue;
  18915. }
  18916. if (':' === $char) {
  18917. $char .= ' ';
  18918. } elseif ('}' === $char || ']' === $char) {
  18919. $pos--;
  18920. $prevChar = substr($json, $i - 1, 1);
  18921. if ('{' !== $prevChar && '[' !== $prevChar) {
  18922. $result .= $newLine;
  18923. for ($j = 0; $j < $pos; $j++) {
  18924. $result .= $indentStr;
  18925. }
  18926. } else {
  18927. $result = rtrim($result);
  18928. }
  18929. }
  18930. $result .= $char;
  18931. if (',' === $char || '{' === $char || '[' === $char) {
  18932. $result .= $newLine;
  18933. if ('{' === $char || '[' === $char) {
  18934. $pos++;
  18935. }
  18936. for ($j = 0; $j < $pos; $j++) {
  18937. $result .= $indentStr;
  18938. }
  18939. }
  18940. }
  18941. return $result;
  18942. }
  18943. }
  18944. <?php
  18945. namespace Composer\Json;
  18946. use Composer\Repository\PlatformRepository;
  18947. class JsonManipulator
  18948. {
  18949. private static $DEFINES = '(?(DEFINE)
  18950. (?<number> -? (?= [1-9]|0(?!\d) ) \d++ (\.\d++)? ([eE] [+-]?+ \d++)? )
  18951. (?<boolean> true | false | null )
  18952. (?<string> " ([^"\\\\]*+ | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  18953. (?<array> \[ (?: (?&json) \s*+ (?: , (?&json) \s*+ )*+ )?+ \s*+ \] )
  18954. (?<pair> \s*+ (?&string) \s*+ : (?&json) \s*+ )
  18955. (?<object> \{ (?: (?&pair) (?: , (?&pair) )*+ )?+ \s*+ \} )
  18956. (?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  18957. )';
  18958. private $contents;
  18959. private $newline;
  18960. private $indent;
  18961. public function __construct($contents)
  18962. {
  18963. $contents = trim($contents);
  18964. if ($contents === '') {
  18965. $contents = '{}';
  18966. }
  18967. if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
  18968. throw new \InvalidArgumentException('The json file must be an object ({})');
  18969. }
  18970. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  18971. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  18972. $this->detectIndenting();
  18973. }
  18974. public function getContents()
  18975. {
  18976. return $this->contents . $this->newline;
  18977. }
  18978. public function addLink($type, $package, $constraint, $sortPackages = false)
  18979. {
  18980. $decoded = JsonFile::parseJson($this->contents);
  18981. if (!isset($decoded[$type])) {
  18982. return $this->addMainKey($type, array($package => $constraint));
  18983. }
  18984. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18985. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  18986. if (!$this->pregMatch($regex, $this->contents, $matches)) {
  18987. return false;
  18988. }
  18989. $links = $matches['value'];
  18990. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  18991. $regex = '{'.self::$DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  18992. if ($this->pregMatch($regex, $links, $packageMatches)) {
  18993. $existingPackage = $packageMatches['package'];
  18994. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  18995. $links = preg_replace_callback('{'.self::$DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', function ($m) use ($existingPackage, $constraint) {
  18996. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  18997. }, $links);
  18998. } else {
  18999. if ($this->pregMatch('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  19000. $links = preg_replace(
  19001. '{'.preg_quote($match[1]).'$}',
  19002. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  19003. $links
  19004. );
  19005. } else {
  19006. $links = '{' . $this->newline .
  19007. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  19008. $this->indent . '}';
  19009. }
  19010. }
  19011. if (true === $sortPackages) {
  19012. $requirements = json_decode($links, true);
  19013. $this->sortPackages($requirements);
  19014. $links = $this->format($requirements);
  19015. }
  19016. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  19017. return true;
  19018. }
  19019. private function sortPackages(array &$packages = array())
  19020. {
  19021. $prefix = function ($requirement) {
  19022. if (PlatformRepository::isPlatformPackage($requirement)) {
  19023. return preg_replace(
  19024. array(
  19025. '/^php/',
  19026. '/^hhvm/',
  19027. '/^ext/',
  19028. '/^lib/',
  19029. '/^\D/',
  19030. ),
  19031. array(
  19032. '0-$0',
  19033. '1-$0',
  19034. '2-$0',
  19035. '3-$0',
  19036. '4-$0',
  19037. ),
  19038. $requirement
  19039. );
  19040. }
  19041. return '5-'.$requirement;
  19042. };
  19043. uksort($packages, function ($a, $b) use ($prefix) {
  19044. return strnatcmp($prefix($a), $prefix($b));
  19045. });
  19046. }
  19047. public function addRepository($name, $config, $append = true)
  19048. {
  19049. return $this->addSubNode('repositories', $name, $config, $append);
  19050. }
  19051. public function removeRepository($name)
  19052. {
  19053. return $this->removeSubNode('repositories', $name);
  19054. }
  19055. public function addConfigSetting($name, $value)
  19056. {
  19057. return $this->addSubNode('config', $name, $value);
  19058. }
  19059. public function removeConfigSetting($name)
  19060. {
  19061. return $this->removeSubNode('config', $name);
  19062. }
  19063. public function addProperty($name, $value)
  19064. {
  19065. if (strpos($name, 'suggest.') === 0) {
  19066. return $this->addSubNode('suggest', substr($name, 8), $value);
  19067. }
  19068. if (strpos($name, 'extra.') === 0) {
  19069. return $this->addSubNode('extra', substr($name, 6), $value);
  19070. }
  19071. if (strpos($name, 'scripts.') === 0) {
  19072. return $this->addSubNode('scripts', substr($name, 8), $value);
  19073. }
  19074. return $this->addMainKey($name, $value);
  19075. }
  19076. public function removeProperty($name)
  19077. {
  19078. if (strpos($name, 'suggest.') === 0) {
  19079. return $this->removeSubNode('suggest', substr($name, 8));
  19080. }
  19081. if (strpos($name, 'extra.') === 0) {
  19082. return $this->removeSubNode('extra', substr($name, 6));
  19083. }
  19084. if (strpos($name, 'scripts.') === 0) {
  19085. return $this->removeSubNode('scripts', substr($name, 8));
  19086. }
  19087. return $this->removeMainKey($name);
  19088. }
  19089. public function addSubNode($mainNode, $name, $value, $append = true)
  19090. {
  19091. $decoded = JsonFile::parseJson($this->contents);
  19092. $subName = null;
  19093. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  19094. list($name, $subName) = explode('.', $name, 2);
  19095. }
  19096. if (!isset($decoded[$mainNode])) {
  19097. if ($subName !== null) {
  19098. $this->addMainKey($mainNode, array($name => array($subName => $value)));
  19099. } else {
  19100. $this->addMainKey($mainNode, array($name => $value));
  19101. }
  19102. return true;
  19103. }
  19104. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  19105. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  19106. try {
  19107. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  19108. return false;
  19109. }
  19110. } catch (\RuntimeException $e) {
  19111. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  19112. return false;
  19113. }
  19114. throw $e;
  19115. }
  19116. $children = $match['content'];
  19117. if (!@json_decode($children)) {
  19118. return false;
  19119. }
  19120. $that = $this;
  19121. $childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  19122. if ($this->pregMatch($childRegex, $children, $matches)) {
  19123. $children = preg_replace_callback($childRegex, function ($matches) use ($subName, $value, $that) {
  19124. if ($subName !== null) {
  19125. $curVal = json_decode($matches['content'], true);
  19126. if (!is_array($curVal)) {
  19127. $curVal = array();
  19128. }
  19129. $curVal[$subName] = $value;
  19130. $value = $curVal;
  19131. }
  19132. return $matches['start'] . $that->format($value, 1) . $matches['end'];
  19133. }, $children);
  19134. } else {
  19135. $this->pregMatch('#^{ (?P<leadingspace>\s*?) (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  19136. $whitespace = '';
  19137. if (!empty($match['trailingspace'])) {
  19138. $whitespace = $match['trailingspace'];
  19139. }
  19140. if (!empty($match['content'])) {
  19141. if ($subName !== null) {
  19142. $value = array($subName => $value);
  19143. }
  19144. if ($append) {
  19145. $children = preg_replace(
  19146. '#'.$whitespace.'}$#',
  19147. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  19148. $children
  19149. );
  19150. } else {
  19151. $whitespace = '';
  19152. if (!empty($match['leadingspace'])) {
  19153. $whitespace = $match['leadingspace'];
  19154. }
  19155. $children = preg_replace(
  19156. '#^{'.$whitespace.'#',
  19157. addcslashes('{' . $whitespace . JsonFile::encode($name).': '.$this->format($value, 1) . ',' . $this->newline . $this->indent . $this->indent, '\\$'),
  19158. $children
  19159. );
  19160. }
  19161. } else {
  19162. if ($subName !== null) {
  19163. $value = array($subName => $value);
  19164. }
  19165. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  19166. }
  19167. }
  19168. $this->contents = preg_replace_callback($nodeRegex, function ($m) use ($children) {
  19169. return $m['start'] . $children . $m['end'];
  19170. }, $this->contents);
  19171. return true;
  19172. }
  19173. public function removeSubNode($mainNode, $name)
  19174. {
  19175. $decoded = JsonFile::parseJson($this->contents);
  19176. if (empty($decoded[$mainNode])) {
  19177. return true;
  19178. }
  19179. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  19180. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  19181. try {
  19182. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  19183. return false;
  19184. }
  19185. } catch (\RuntimeException $e) {
  19186. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  19187. return false;
  19188. }
  19189. throw $e;
  19190. }
  19191. $children = $match['content'];
  19192. if (!@json_decode($children, true)) {
  19193. return false;
  19194. }
  19195. $subName = null;
  19196. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  19197. list($name, $subName) = explode('.', $name, 2);
  19198. }
  19199. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  19200. return true;
  19201. }
  19202. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  19203. if ($this->pregMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  19204. if (preg_match_all('{'.self::$DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  19205. $bestMatch = '';
  19206. foreach ($matches[0] as $match) {
  19207. if (strlen($bestMatch) < strlen($match)) {
  19208. $bestMatch = $match;
  19209. }
  19210. }
  19211. $childrenClean = preg_replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  19212. if (1 !== $count) {
  19213. $childrenClean = preg_replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  19214. if (1 !== $count) {
  19215. return false;
  19216. }
  19217. }
  19218. }
  19219. } else {
  19220. $childrenClean = $children;
  19221. }
  19222. if (!isset($childrenClean)) {
  19223. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  19224. }
  19225. $this->pregMatch('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  19226. if (empty($match['content'])) {
  19227. $newline = $this->newline;
  19228. $indent = $this->indent;
  19229. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($indent, $newline) {
  19230. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  19231. }, $this->contents);
  19232. if ($subName !== null) {
  19233. $curVal = json_decode($children, true);
  19234. unset($curVal[$name][$subName]);
  19235. $this->addSubNode($mainNode, $name, $curVal[$name]);
  19236. }
  19237. return true;
  19238. }
  19239. $that = $this;
  19240. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($that, $name, $subName, $childrenClean) {
  19241. if ($subName !== null) {
  19242. $curVal = json_decode($matches['content'], true);
  19243. unset($curVal[$name][$subName]);
  19244. $childrenClean = $that->format($curVal);
  19245. }
  19246. return $matches['start'] . $childrenClean . $matches['end'];
  19247. }, $this->contents);
  19248. return true;
  19249. }
  19250. public function addMainKey($key, $content)
  19251. {
  19252. $decoded = JsonFile::parseJson($this->contents);
  19253. $content = $this->format($content);
  19254. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  19255. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  19256. if (isset($decoded[$key]) && $this->pregMatch($regex, $this->contents, $matches)) {
  19257. if (!@json_decode('{'.$matches['key'].'}')) {
  19258. return false;
  19259. }
  19260. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  19261. return true;
  19262. }
  19263. if ($this->pregMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  19264. $this->contents = preg_replace(
  19265. '#'.$match[1].'\}$#',
  19266. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  19267. $this->contents
  19268. );
  19269. return true;
  19270. }
  19271. $this->contents = preg_replace(
  19272. '#\}$#',
  19273. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  19274. $this->contents
  19275. );
  19276. return true;
  19277. }
  19278. public function removeMainKey($key)
  19279. {
  19280. $decoded = JsonFile::parseJson($this->contents);
  19281. if (!array_key_exists($key, $decoded)) {
  19282. return true;
  19283. }
  19284. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  19285. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  19286. if ($this->pregMatch($regex, $this->contents, $matches)) {
  19287. if (!@json_decode('{'.$matches['removal'].'}')) {
  19288. return false;
  19289. }
  19290. if (preg_match('#,\s*$#', $matches['start']) && preg_match('#^\}$#', $matches['end'])) {
  19291. $matches['start'] = rtrim(preg_replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  19292. }
  19293. $this->contents = $matches['start'] . $matches['end'];
  19294. if (preg_match('#^\{\s*\}\s*$#', $this->contents)) {
  19295. $this->contents = "{\n}";
  19296. }
  19297. return true;
  19298. }
  19299. return false;
  19300. }
  19301. public function removeMainKeyIfEmpty($key)
  19302. {
  19303. $decoded = JsonFile::parseJson($this->contents);
  19304. if (!array_key_exists($key, $decoded)) {
  19305. return true;
  19306. }
  19307. if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
  19308. return $this->removeMainKey($key);
  19309. }
  19310. return true;
  19311. }
  19312. public function format($data, $depth = 0)
  19313. {
  19314. if (is_array($data)) {
  19315. reset($data);
  19316. if (is_numeric(key($data))) {
  19317. foreach ($data as $key => $val) {
  19318. $data[$key] = $this->format($val, $depth + 1);
  19319. }
  19320. return '['.implode(', ', $data).']';
  19321. }
  19322. $out = '{' . $this->newline;
  19323. $elems = array();
  19324. foreach ($data as $key => $val) {
  19325. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  19326. }
  19327. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  19328. }
  19329. return JsonFile::encode($data);
  19330. }
  19331. protected function detectIndenting()
  19332. {
  19333. if ($this->pregMatch('{^([ \t]+)"}m', $this->contents, $match)) {
  19334. $this->indent = $match[1];
  19335. } else {
  19336. $this->indent = ' ';
  19337. }
  19338. }
  19339. protected function pregMatch($re, $str, &$matches = array())
  19340. {
  19341. $count = preg_match($re, $str, $matches);
  19342. if ($count === false) {
  19343. switch (preg_last_error()) {
  19344. case PREG_NO_ERROR:
  19345. throw new \RuntimeException('Failed to execute regex: PREG_NO_ERROR', PREG_NO_ERROR);
  19346. case PREG_INTERNAL_ERROR:
  19347. throw new \RuntimeException('Failed to execute regex: PREG_INTERNAL_ERROR', PREG_INTERNAL_ERROR);
  19348. case PREG_BACKTRACK_LIMIT_ERROR:
  19349. throw new \RuntimeException('Failed to execute regex: PREG_BACKTRACK_LIMIT_ERROR', PREG_BACKTRACK_LIMIT_ERROR);
  19350. case PREG_RECURSION_LIMIT_ERROR:
  19351. throw new \RuntimeException('Failed to execute regex: PREG_RECURSION_LIMIT_ERROR', PREG_RECURSION_LIMIT_ERROR);
  19352. case PREG_BAD_UTF8_ERROR:
  19353. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_ERROR', PREG_BAD_UTF8_ERROR);
  19354. case PREG_BAD_UTF8_OFFSET_ERROR:
  19355. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_OFFSET_ERROR', PREG_BAD_UTF8_OFFSET_ERROR);
  19356. case 6:
  19357. if (PHP_VERSION_ID > 70000) {
  19358. throw new \RuntimeException('Failed to execute regex: PREG_JIT_STACKLIMIT_ERROR', 6);
  19359. }
  19360. default:
  19361. throw new \RuntimeException('Failed to execute regex: Unknown error');
  19362. }
  19363. }
  19364. return $count;
  19365. }
  19366. }
  19367. <?php
  19368. namespace Composer\Json;
  19369. use Exception;
  19370. class JsonValidationException extends Exception
  19371. {
  19372. protected $errors;
  19373. public function __construct($message, $errors = array(), Exception $previous = null)
  19374. {
  19375. $this->errors = $errors;
  19376. parent::__construct((string) $message, 0, $previous);
  19377. }
  19378. public function getErrors()
  19379. {
  19380. return $this->errors;
  19381. }
  19382. }
  19383. <?php
  19384. namespace Composer\Package;
  19385. use Composer\Semver\Constraint\Constraint;
  19386. use Composer\Package\Version\VersionParser;
  19387. class AliasPackage extends BasePackage
  19388. {
  19389. protected $version;
  19390. protected $prettyVersion;
  19391. protected $dev;
  19392. protected $rootPackageAlias = false;
  19393. protected $stability;
  19394. protected $hasSelfVersionRequires = false;
  19395. protected $aliasOf;
  19396. protected $requires;
  19397. protected $devRequires;
  19398. protected $conflicts;
  19399. protected $provides;
  19400. protected $replaces;
  19401. public function __construct(BasePackage $aliasOf, $version, $prettyVersion)
  19402. {
  19403. parent::__construct($aliasOf->getName());
  19404. $this->version = $version;
  19405. $this->prettyVersion = $prettyVersion;
  19406. $this->aliasOf = $aliasOf;
  19407. $this->stability = VersionParser::parseStability($version);
  19408. $this->dev = $this->stability === 'dev';
  19409. foreach (Link::$TYPES as $type) {
  19410. $links = $aliasOf->{'get' . ucfirst($type)}();
  19411. $this->$type = $this->replaceSelfVersionDependencies($links, $type);
  19412. }
  19413. }
  19414. public function getAliasOf()
  19415. {
  19416. return $this->aliasOf;
  19417. }
  19418. public function getVersion()
  19419. {
  19420. return $this->version;
  19421. }
  19422. public function getStability()
  19423. {
  19424. return $this->stability;
  19425. }
  19426. public function getPrettyVersion()
  19427. {
  19428. return $this->prettyVersion;
  19429. }
  19430. public function isDev()
  19431. {
  19432. return $this->dev;
  19433. }
  19434. public function getRequires()
  19435. {
  19436. return $this->requires;
  19437. }
  19438. public function getConflicts()
  19439. {
  19440. return $this->conflicts;
  19441. }
  19442. public function getProvides()
  19443. {
  19444. return $this->provides;
  19445. }
  19446. public function getReplaces()
  19447. {
  19448. return $this->replaces;
  19449. }
  19450. public function getDevRequires()
  19451. {
  19452. return $this->devRequires;
  19453. }
  19454. public function setRootPackageAlias($value)
  19455. {
  19456. return $this->rootPackageAlias = $value;
  19457. }
  19458. public function isRootPackageAlias()
  19459. {
  19460. return $this->rootPackageAlias;
  19461. }
  19462. protected function replaceSelfVersionDependencies(array $links, $linkType)
  19463. {
  19464. $prettyVersion = $this->prettyVersion;
  19465. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  19466. $prettyVersion = $this->aliasOf->getPrettyVersion();
  19467. }
  19468. if (\in_array($linkType, array(Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE), true)) {
  19469. $newLinks = array();
  19470. foreach ($links as $link) {
  19471. if ('self.version' === $link->getPrettyConstraint()) {
  19472. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  19473. $constraint->setPrettyString($prettyVersion);
  19474. }
  19475. }
  19476. $links = array_merge($links, $newLinks);
  19477. } else {
  19478. foreach ($links as $index => $link) {
  19479. if ('self.version' === $link->getPrettyConstraint()) {
  19480. if ($linkType === Link::TYPE_REQUIRE) {
  19481. $this->hasSelfVersionRequires = true;
  19482. }
  19483. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  19484. $constraint->setPrettyString($prettyVersion);
  19485. }
  19486. }
  19487. }
  19488. return $links;
  19489. }
  19490. public function hasSelfVersionRequires()
  19491. {
  19492. return $this->hasSelfVersionRequires;
  19493. }
  19494. public function __toString()
  19495. {
  19496. return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
  19497. }
  19498. public function getType()
  19499. {
  19500. return $this->aliasOf->getType();
  19501. }
  19502. public function getTargetDir()
  19503. {
  19504. return $this->aliasOf->getTargetDir();
  19505. }
  19506. public function getExtra()
  19507. {
  19508. return $this->aliasOf->getExtra();
  19509. }
  19510. public function setInstallationSource($type)
  19511. {
  19512. $this->aliasOf->setInstallationSource($type);
  19513. }
  19514. public function getInstallationSource()
  19515. {
  19516. return $this->aliasOf->getInstallationSource();
  19517. }
  19518. public function getSourceType()
  19519. {
  19520. return $this->aliasOf->getSourceType();
  19521. }
  19522. public function getSourceUrl()
  19523. {
  19524. return $this->aliasOf->getSourceUrl();
  19525. }
  19526. public function getSourceUrls()
  19527. {
  19528. return $this->aliasOf->getSourceUrls();
  19529. }
  19530. public function getSourceReference()
  19531. {
  19532. return $this->aliasOf->getSourceReference();
  19533. }
  19534. public function setSourceReference($reference)
  19535. {
  19536. $this->aliasOf->setSourceReference($reference);
  19537. }
  19538. public function setSourceMirrors($mirrors)
  19539. {
  19540. $this->aliasOf->setSourceMirrors($mirrors);
  19541. }
  19542. public function getSourceMirrors()
  19543. {
  19544. return $this->aliasOf->getSourceMirrors();
  19545. }
  19546. public function getDistType()
  19547. {
  19548. return $this->aliasOf->getDistType();
  19549. }
  19550. public function getDistUrl()
  19551. {
  19552. return $this->aliasOf->getDistUrl();
  19553. }
  19554. public function getDistUrls()
  19555. {
  19556. return $this->aliasOf->getDistUrls();
  19557. }
  19558. public function getDistReference()
  19559. {
  19560. return $this->aliasOf->getDistReference();
  19561. }
  19562. public function setDistReference($reference)
  19563. {
  19564. $this->aliasOf->setDistReference($reference);
  19565. }
  19566. public function getDistSha1Checksum()
  19567. {
  19568. return $this->aliasOf->getDistSha1Checksum();
  19569. }
  19570. public function setTransportOptions(array $options)
  19571. {
  19572. $this->aliasOf->setTransportOptions($options);
  19573. }
  19574. public function getTransportOptions()
  19575. {
  19576. return $this->aliasOf->getTransportOptions();
  19577. }
  19578. public function setDistMirrors($mirrors)
  19579. {
  19580. $this->aliasOf->setDistMirrors($mirrors);
  19581. }
  19582. public function getDistMirrors()
  19583. {
  19584. return $this->aliasOf->getDistMirrors();
  19585. }
  19586. public function getAutoload()
  19587. {
  19588. return $this->aliasOf->getAutoload();
  19589. }
  19590. public function getDevAutoload()
  19591. {
  19592. return $this->aliasOf->getDevAutoload();
  19593. }
  19594. public function getIncludePaths()
  19595. {
  19596. return $this->aliasOf->getIncludePaths();
  19597. }
  19598. public function getReleaseDate()
  19599. {
  19600. return $this->aliasOf->getReleaseDate();
  19601. }
  19602. public function getBinaries()
  19603. {
  19604. return $this->aliasOf->getBinaries();
  19605. }
  19606. public function getSuggests()
  19607. {
  19608. return $this->aliasOf->getSuggests();
  19609. }
  19610. public function getNotificationUrl()
  19611. {
  19612. return $this->aliasOf->getNotificationUrl();
  19613. }
  19614. public function isDefaultBranch()
  19615. {
  19616. return $this->aliasOf->isDefaultBranch();
  19617. }
  19618. public function setDistUrl($url)
  19619. {
  19620. $this->aliasOf->setDistUrl($url);
  19621. }
  19622. public function setDistType($type)
  19623. {
  19624. $this->aliasOf->setDistType($type);
  19625. }
  19626. public function setSourceDistReferences($reference)
  19627. {
  19628. $this->aliasOf->setSourceDistReferences($reference);
  19629. }
  19630. }
  19631. <?php
  19632. namespace Composer\Package\Archiver;
  19633. use FilterIterator;
  19634. use PharData;
  19635. class ArchivableFilesFilter extends FilterIterator
  19636. {
  19637. private $dirs = array();
  19638. #[\ReturnTypeWillChange]
  19639. public function accept()
  19640. {
  19641. $file = $this->getInnerIterator()->current();
  19642. if ($file->isDir()) {
  19643. $this->dirs[] = (string) $file;
  19644. return false;
  19645. }
  19646. return true;
  19647. }
  19648. public function addEmptyDir(PharData $phar, $sources)
  19649. {
  19650. foreach ($this->dirs as $filepath) {
  19651. $localname = str_replace($sources . "/", '', $filepath);
  19652. $phar->addEmptyDir($localname);
  19653. }
  19654. }
  19655. }
  19656. <?php
  19657. namespace Composer\Package\Archiver;
  19658. use Composer\Util\Filesystem;
  19659. use FilesystemIterator;
  19660. use Symfony\Component\Finder\Finder;
  19661. use Symfony\Component\Finder\SplFileInfo;
  19662. class ArchivableFilesFinder extends \FilterIterator
  19663. {
  19664. protected $finder;
  19665. public function __construct($sources, array $excludes, $ignoreFilters = false)
  19666. {
  19667. $fs = new Filesystem();
  19668. $sources = $fs->normalizePath(realpath($sources));
  19669. if ($ignoreFilters) {
  19670. $filters = array();
  19671. } else {
  19672. $filters = array(
  19673. new HgExcludeFilter($sources),
  19674. new GitExcludeFilter($sources),
  19675. new ComposerExcludeFilter($sources, $excludes),
  19676. );
  19677. }
  19678. $this->finder = new Finder();
  19679. $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) {
  19680. if ($file->isLink() && strpos($file->getRealPath(), $sources) !== 0) {
  19681. return false;
  19682. }
  19683. $relativePath = preg_replace(
  19684. '#^'.preg_quote($sources, '#').'#',
  19685. '',
  19686. $fs->normalizePath($file->getRealPath())
  19687. );
  19688. $exclude = false;
  19689. foreach ($filters as $filter) {
  19690. $exclude = $filter->filter($relativePath, $exclude);
  19691. }
  19692. return !$exclude;
  19693. };
  19694. if (method_exists($filter, 'bindTo')) {
  19695. $filter = $filter->bindTo(null);
  19696. }
  19697. $this->finder
  19698. ->in($sources)
  19699. ->filter($filter)
  19700. ->ignoreVCS(true)
  19701. ->ignoreDotFiles(false);
  19702. parent::__construct($this->finder->getIterator());
  19703. }
  19704. #[\ReturnTypeWillChange]
  19705. public function accept()
  19706. {
  19707. $current = $this->getInnerIterator()->current();
  19708. if (!$current->isDir()) {
  19709. return true;
  19710. }
  19711. $iterator = new FilesystemIterator($current, FilesystemIterator::SKIP_DOTS);
  19712. return !$iterator->valid();
  19713. }
  19714. }
  19715. <?php
  19716. namespace Composer\Package\Archiver;
  19717. use Composer\Downloader\DownloadManager;
  19718. use Composer\Package\RootPackageInterface;
  19719. use Composer\Util\Filesystem;
  19720. use Composer\Util\Loop;
  19721. use Composer\Util\SyncHelper;
  19722. use Composer\Json\JsonFile;
  19723. use Composer\Package\CompletePackageInterface;
  19724. class ArchiveManager
  19725. {
  19726. protected $downloadManager;
  19727. protected $loop;
  19728. protected $archivers = array();
  19729. protected $overwriteFiles = true;
  19730. public function __construct(DownloadManager $downloadManager, Loop $loop)
  19731. {
  19732. $this->downloadManager = $downloadManager;
  19733. $this->loop = $loop;
  19734. }
  19735. public function addArchiver(ArchiverInterface $archiver)
  19736. {
  19737. $this->archivers[] = $archiver;
  19738. }
  19739. public function setOverwriteFiles($overwriteFiles)
  19740. {
  19741. $this->overwriteFiles = $overwriteFiles;
  19742. return $this;
  19743. }
  19744. public function getPackageFilename(CompletePackageInterface $package)
  19745. {
  19746. if ($package->getArchiveName()) {
  19747. $baseName = $package->getArchiveName();
  19748. } else {
  19749. $baseName = preg_replace('#[^a-z0-9-_]#i', '-', $package->getName());
  19750. }
  19751. $nameParts = array($baseName);
  19752. if (null !== $package->getDistReference() && preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
  19753. array_push($nameParts, $package->getDistReference(), $package->getDistType());
  19754. } else {
  19755. array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
  19756. }
  19757. if ($package->getSourceReference()) {
  19758. $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
  19759. }
  19760. $name = implode('-', array_filter($nameParts, function ($p) {
  19761. return !empty($p);
  19762. }));
  19763. return str_replace('/', '-', $name);
  19764. }
  19765. public function archive(CompletePackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false)
  19766. {
  19767. if (empty($format)) {
  19768. throw new \InvalidArgumentException('Format must be specified');
  19769. }
  19770. $usableArchiver = null;
  19771. foreach ($this->archivers as $archiver) {
  19772. if ($archiver->supports($format, $package->getSourceType())) {
  19773. $usableArchiver = $archiver;
  19774. break;
  19775. }
  19776. }
  19777. if (null === $usableArchiver) {
  19778. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  19779. }
  19780. $filesystem = new Filesystem();
  19781. if ($package instanceof RootPackageInterface) {
  19782. $sourcePath = realpath('.');
  19783. } else {
  19784. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  19785. $filesystem->ensureDirectoryExists($sourcePath);
  19786. try {
  19787. $promise = $this->downloadManager->download($package, $sourcePath);
  19788. SyncHelper::await($this->loop, $promise);
  19789. $promise = $this->downloadManager->install($package, $sourcePath);
  19790. SyncHelper::await($this->loop, $promise);
  19791. } catch (\Exception $e) {
  19792. $filesystem->removeDirectory($sourcePath);
  19793. throw $e;
  19794. }
  19795. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  19796. $jsonFile = new JsonFile($composerJsonPath);
  19797. $jsonData = $jsonFile->read();
  19798. if (!empty($jsonData['archive']['name'])) {
  19799. $package->setArchiveName($jsonData['archive']['name']);
  19800. }
  19801. if (!empty($jsonData['archive']['exclude'])) {
  19802. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  19803. }
  19804. }
  19805. }
  19806. if (null === $fileName) {
  19807. $packageName = $this->getPackageFilename($package);
  19808. } else {
  19809. $packageName = $fileName;
  19810. }
  19811. $filesystem->ensureDirectoryExists($targetDir);
  19812. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  19813. $filesystem->ensureDirectoryExists(dirname($target));
  19814. if (!$this->overwriteFiles && file_exists($target)) {
  19815. return $target;
  19816. }
  19817. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  19818. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  19819. $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
  19820. $filesystem->rename($archivePath, $target);
  19821. if (!$package instanceof RootPackageInterface) {
  19822. $filesystem->removeDirectory($sourcePath);
  19823. }
  19824. $filesystem->remove($tempTarget);
  19825. return $target;
  19826. }
  19827. }
  19828. <?php
  19829. namespace Composer\Package\Archiver;
  19830. interface ArchiverInterface
  19831. {
  19832. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false);
  19833. public function supports($format, $sourceType);
  19834. }
  19835. <?php
  19836. namespace Composer\Package\Archiver;
  19837. use Symfony\Component\Finder;
  19838. abstract class BaseExcludeFilter
  19839. {
  19840. protected $sourcePath;
  19841. protected $excludePatterns;
  19842. public function __construct($sourcePath)
  19843. {
  19844. $this->sourcePath = $sourcePath;
  19845. $this->excludePatterns = array();
  19846. }
  19847. public function filter($relativePath, $exclude)
  19848. {
  19849. foreach ($this->excludePatterns as $patternData) {
  19850. list($pattern, $negate, $stripLeadingSlash) = $patternData;
  19851. if ($stripLeadingSlash) {
  19852. $path = substr($relativePath, 1);
  19853. } else {
  19854. $path = $relativePath;
  19855. }
  19856. if (@preg_match($pattern, $path)) {
  19857. $exclude = !$negate;
  19858. }
  19859. }
  19860. return $exclude;
  19861. }
  19862. protected function parseLines(array $lines, $lineParser)
  19863. {
  19864. return array_filter(
  19865. array_map(
  19866. function ($line) use ($lineParser) {
  19867. $line = trim($line);
  19868. if (!$line || 0 === strpos($line, '#')) {
  19869. return null;
  19870. }
  19871. return call_user_func($lineParser, $line);
  19872. },
  19873. $lines
  19874. ),
  19875. function ($pattern) {
  19876. return $pattern !== null;
  19877. }
  19878. );
  19879. }
  19880. protected function generatePatterns($rules)
  19881. {
  19882. $patterns = array();
  19883. foreach ($rules as $rule) {
  19884. $patterns[] = $this->generatePattern($rule);
  19885. }
  19886. return $patterns;
  19887. }
  19888. protected function generatePattern($rule)
  19889. {
  19890. $negate = false;
  19891. $pattern = '';
  19892. if ($rule !== '' && $rule[0] === '!') {
  19893. $negate = true;
  19894. $rule = ltrim($rule, '!');
  19895. }
  19896. $firstSlashPosition = strpos($rule, '/');
  19897. if (0 === $firstSlashPosition) {
  19898. $pattern = '^/';
  19899. } elseif (false === $firstSlashPosition || strlen($rule) - 1 === $firstSlashPosition) {
  19900. $pattern = '/';
  19901. }
  19902. $rule = trim($rule, '/');
  19903. $rule = substr(Finder\Glob::toRegex($rule), 2, -2);
  19904. return array('{'.$pattern.$rule.'(?=$|/)}', $negate, false);
  19905. }
  19906. }
  19907. <?php
  19908. namespace Composer\Package\Archiver;
  19909. class ComposerExcludeFilter extends BaseExcludeFilter
  19910. {
  19911. public function __construct($sourcePath, array $excludeRules)
  19912. {
  19913. parent::__construct($sourcePath);
  19914. $this->excludePatterns = $this->generatePatterns($excludeRules);
  19915. }
  19916. }
  19917. <?php
  19918. namespace Composer\Package\Archiver;
  19919. class GitExcludeFilter extends BaseExcludeFilter
  19920. {
  19921. public function __construct($sourcePath)
  19922. {
  19923. parent::__construct($sourcePath);
  19924. if (file_exists($sourcePath.'/.gitignore')) {
  19925. $this->excludePatterns = $this->parseLines(
  19926. file($sourcePath.'/.gitignore'),
  19927. array($this, 'parseGitIgnoreLine')
  19928. );
  19929. }
  19930. if (file_exists($sourcePath.'/.gitattributes')) {
  19931. $this->excludePatterns = array_merge(
  19932. $this->excludePatterns,
  19933. $this->parseLines(
  19934. file($sourcePath.'/.gitattributes'),
  19935. array($this, 'parseGitAttributesLine')
  19936. )
  19937. );
  19938. }
  19939. }
  19940. public function parseGitIgnoreLine($line)
  19941. {
  19942. return $this->generatePattern($line);
  19943. }
  19944. public function parseGitAttributesLine($line)
  19945. {
  19946. $parts = preg_split('#\s+#', $line);
  19947. if (count($parts) == 2 && $parts[1] === 'export-ignore') {
  19948. return $this->generatePattern($parts[0]);
  19949. }
  19950. return null;
  19951. }
  19952. }
  19953. <?php
  19954. namespace Composer\Package\Archiver;
  19955. use Symfony\Component\Finder;
  19956. class HgExcludeFilter extends BaseExcludeFilter
  19957. {
  19958. const HG_IGNORE_REGEX = 1;
  19959. const HG_IGNORE_GLOB = 2;
  19960. protected $patternMode;
  19961. public function __construct($sourcePath)
  19962. {
  19963. parent::__construct($sourcePath);
  19964. $this->patternMode = self::HG_IGNORE_REGEX;
  19965. if (file_exists($sourcePath.'/.hgignore')) {
  19966. $this->excludePatterns = $this->parseLines(
  19967. file($sourcePath.'/.hgignore'),
  19968. array($this, 'parseHgIgnoreLine')
  19969. );
  19970. }
  19971. }
  19972. public function parseHgIgnoreLine($line)
  19973. {
  19974. if (preg_match('#^syntax\s*:\s*(glob|regexp)$#', $line, $matches)) {
  19975. if ($matches[1] === 'glob') {
  19976. $this->patternMode = self::HG_IGNORE_GLOB;
  19977. } else {
  19978. $this->patternMode = self::HG_IGNORE_REGEX;
  19979. }
  19980. return null;
  19981. }
  19982. if ($this->patternMode == self::HG_IGNORE_GLOB) {
  19983. return $this->patternFromGlob($line);
  19984. }
  19985. return $this->patternFromRegex($line);
  19986. }
  19987. protected function patternFromGlob($line)
  19988. {
  19989. $pattern = '#'.substr(Finder\Glob::toRegex($line), 2, -1).'#';
  19990. $pattern = str_replace('[^/]*', '.*', $pattern);
  19991. return array($pattern, false, true);
  19992. }
  19993. public function patternFromRegex($line)
  19994. {
  19995. $pattern = '#'.preg_replace('/((?:\\\\\\\\)*)(\\\\?)#/', '\1\2\2\\#', $line).'#';
  19996. return array($pattern, false, true);
  19997. }
  19998. }
  19999. <?php
  20000. namespace Composer\Package\Archiver;
  20001. class PharArchiver implements ArchiverInterface
  20002. {
  20003. protected static $formats = array(
  20004. 'zip' => \Phar::ZIP,
  20005. 'tar' => \Phar::TAR,
  20006. 'tar.gz' => \Phar::TAR,
  20007. 'tar.bz2' => \Phar::TAR,
  20008. );
  20009. protected static $compressFormats = array(
  20010. 'tar.gz' => \Phar::GZ,
  20011. 'tar.bz2' => \Phar::BZ2,
  20012. );
  20013. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  20014. {
  20015. $sources = realpath($sources);
  20016. if (file_exists($target)) {
  20017. unlink($target);
  20018. }
  20019. try {
  20020. $filename = substr($target, 0, strrpos($target, $format) - 1);
  20021. if (isset(static::$compressFormats[$format])) {
  20022. $target = $filename . '.tar';
  20023. }
  20024. $phar = new \PharData(
  20025. $target,
  20026. \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO,
  20027. '',
  20028. static::$formats[$format]
  20029. );
  20030. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  20031. $filesOnly = new ArchivableFilesFilter($files);
  20032. $phar->buildFromIterator($filesOnly, $sources);
  20033. $filesOnly->addEmptyDir($phar, $sources);
  20034. if (isset(static::$compressFormats[$format])) {
  20035. if (!$phar->canCompress(static::$compressFormats[$format])) {
  20036. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  20037. }
  20038. unlink($target);
  20039. $phar->compress(static::$compressFormats[$format]);
  20040. $target = $filename . '.' . $format;
  20041. }
  20042. return $target;
  20043. } catch (\UnexpectedValueException $e) {
  20044. $message = sprintf(
  20045. "Could not create archive '%s' from '%s': %s",
  20046. $target,
  20047. $sources,
  20048. $e->getMessage()
  20049. );
  20050. throw new \RuntimeException($message, $e->getCode(), $e);
  20051. }
  20052. }
  20053. public function supports($format, $sourceType)
  20054. {
  20055. return isset(static::$formats[$format]);
  20056. }
  20057. }
  20058. <?php
  20059. namespace Composer\Package\Archiver;
  20060. use ZipArchive;
  20061. use Composer\Util\Filesystem;
  20062. class ZipArchiver implements ArchiverInterface
  20063. {
  20064. protected static $formats = array(
  20065. 'zip' => true,
  20066. );
  20067. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  20068. {
  20069. $fs = new Filesystem();
  20070. $sources = $fs->normalizePath($sources);
  20071. $zip = new ZipArchive();
  20072. $res = $zip->open($target, ZipArchive::CREATE);
  20073. if ($res === true) {
  20074. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  20075. foreach ($files as $file) {
  20076. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  20077. $localname = $filepath;
  20078. if (strpos($localname, $sources . '/') === 0) {
  20079. $localname = substr($localname, strlen($sources . '/'));
  20080. }
  20081. if ($file->isDir()) {
  20082. $zip->addEmptyDir($localname);
  20083. } else {
  20084. $zip->addFile($filepath, $localname);
  20085. }
  20086. if (PHP_VERSION_ID >= 50600 && method_exists($zip, 'setExternalAttributesName')) {
  20087. $perms = fileperms($filepath);
  20088. $zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
  20089. }
  20090. }
  20091. if ($zip->close()) {
  20092. return $target;
  20093. }
  20094. }
  20095. $message = sprintf(
  20096. "Could not create archive '%s' from '%s': %s",
  20097. $target,
  20098. $sources,
  20099. $zip->getStatusString()
  20100. );
  20101. throw new \RuntimeException($message);
  20102. }
  20103. public function supports($format, $sourceType)
  20104. {
  20105. return isset(static::$formats[$format]) && $this->compressionAvailable();
  20106. }
  20107. private function compressionAvailable()
  20108. {
  20109. return class_exists('ZipArchive');
  20110. }
  20111. }
  20112. <?php
  20113. namespace Composer\Package;
  20114. use Composer\Repository\RepositoryInterface;
  20115. use Composer\Repository\PlatformRepository;
  20116. abstract class BasePackage implements PackageInterface
  20117. {
  20118. public static $supportedLinkTypes = array(
  20119. 'require' => array('description' => 'requires', 'method' => Link::TYPE_REQUIRE),
  20120. 'conflict' => array('description' => 'conflicts', 'method' => Link::TYPE_CONFLICT),
  20121. 'provide' => array('description' => 'provides', 'method' => Link::TYPE_PROVIDE),
  20122. 'replace' => array('description' => 'replaces', 'method' => Link::TYPE_REPLACE),
  20123. 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
  20124. );
  20125. const STABILITY_STABLE = 0;
  20126. const STABILITY_RC = 5;
  20127. const STABILITY_BETA = 10;
  20128. const STABILITY_ALPHA = 15;
  20129. const STABILITY_DEV = 20;
  20130. public static $stabilities = array(
  20131. 'stable' => self::STABILITY_STABLE,
  20132. 'RC' => self::STABILITY_RC,
  20133. 'beta' => self::STABILITY_BETA,
  20134. 'alpha' => self::STABILITY_ALPHA,
  20135. 'dev' => self::STABILITY_DEV,
  20136. );
  20137. public $id;
  20138. protected $name;
  20139. protected $prettyName;
  20140. protected $repository = null;
  20141. public function __construct($name)
  20142. {
  20143. $this->prettyName = $name;
  20144. $this->name = strtolower($name);
  20145. $this->id = -1;
  20146. }
  20147. public function getName()
  20148. {
  20149. return $this->name;
  20150. }
  20151. public function getPrettyName()
  20152. {
  20153. return $this->prettyName;
  20154. }
  20155. public function getNames($provides = true)
  20156. {
  20157. $names = array(
  20158. $this->getName() => true,
  20159. );
  20160. if ($provides) {
  20161. foreach ($this->getProvides() as $link) {
  20162. $names[$link->getTarget()] = true;
  20163. }
  20164. }
  20165. foreach ($this->getReplaces() as $link) {
  20166. $names[$link->getTarget()] = true;
  20167. }
  20168. return array_keys($names);
  20169. }
  20170. public function setId($id)
  20171. {
  20172. $this->id = $id;
  20173. }
  20174. public function getId()
  20175. {
  20176. return $this->id;
  20177. }
  20178. public function setRepository(RepositoryInterface $repository)
  20179. {
  20180. if ($this->repository && $repository !== $this->repository) {
  20181. throw new \LogicException('A package can only be added to one repository');
  20182. }
  20183. $this->repository = $repository;
  20184. }
  20185. public function getRepository()
  20186. {
  20187. return $this->repository;
  20188. }
  20189. public function isPlatform()
  20190. {
  20191. return $this->getRepository() instanceof PlatformRepository;
  20192. }
  20193. public function getUniqueName()
  20194. {
  20195. return $this->getName().'-'.$this->getVersion();
  20196. }
  20197. public function equals(PackageInterface $package)
  20198. {
  20199. $self = $this;
  20200. if ($this instanceof AliasPackage) {
  20201. $self = $this->getAliasOf();
  20202. }
  20203. if ($package instanceof AliasPackage) {
  20204. $package = $package->getAliasOf();
  20205. }
  20206. return $package === $self;
  20207. }
  20208. public function __toString()
  20209. {
  20210. return $this->getUniqueName();
  20211. }
  20212. public function getPrettyString()
  20213. {
  20214. return $this->getPrettyName().' '.$this->getPrettyVersion();
  20215. }
  20216. public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
  20217. {
  20218. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  20219. (!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
  20220. ) {
  20221. return $this->getPrettyVersion();
  20222. }
  20223. switch ($displayMode) {
  20224. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  20225. case PackageInterface::DISPLAY_SOURCE_REF:
  20226. $reference = $this->getSourceReference();
  20227. break;
  20228. case PackageInterface::DISPLAY_DIST_REF:
  20229. $reference = $this->getDistReference();
  20230. break;
  20231. default:
  20232. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  20233. }
  20234. if (null === $reference) {
  20235. return $this->getPrettyVersion();
  20236. }
  20237. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  20238. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  20239. }
  20240. return $this->getPrettyVersion() . ' ' . $reference;
  20241. }
  20242. public function getStabilityPriority()
  20243. {
  20244. return self::$stabilities[$this->getStability()];
  20245. }
  20246. public function __clone()
  20247. {
  20248. $this->repository = null;
  20249. $this->id = -1;
  20250. }
  20251. public static function packageNameToRegexp($allowPattern, $wrap = '{^%s$}i')
  20252. {
  20253. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  20254. return sprintf($wrap, $cleanedAllowPattern);
  20255. }
  20256. }
  20257. <?php
  20258. namespace Composer\Package\Comparer;
  20259. class Comparer
  20260. {
  20261. private $source;
  20262. private $update;
  20263. private $changed;
  20264. public function setSource($source)
  20265. {
  20266. $this->source = $source;
  20267. }
  20268. public function setUpdate($update)
  20269. {
  20270. $this->update = $update;
  20271. }
  20272. public function getChanged($toString = false, $explicated = false)
  20273. {
  20274. $changed = $this->changed;
  20275. if (!count($changed)) {
  20276. return false;
  20277. }
  20278. if ($explicated) {
  20279. foreach ($changed as $sectionKey => $itemSection) {
  20280. foreach ($itemSection as $itemKey => $item) {
  20281. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  20282. }
  20283. }
  20284. }
  20285. if ($toString) {
  20286. foreach ($changed as $sectionKey => $itemSection) {
  20287. foreach ($itemSection as $itemKey => $item) {
  20288. $changed['string'][] = $item."\r\n";
  20289. }
  20290. }
  20291. $changed = implode("\r\n", $changed['string']);
  20292. }
  20293. return $changed;
  20294. }
  20295. public function doCompare()
  20296. {
  20297. $source = array();
  20298. $destination = array();
  20299. $this->changed = array();
  20300. $currentDirectory = getcwd();
  20301. chdir($this->source);
  20302. $source = $this->doTree('.', $source);
  20303. if (!is_array($source)) {
  20304. return;
  20305. }
  20306. chdir($currentDirectory);
  20307. chdir($this->update);
  20308. $destination = $this->doTree('.', $destination);
  20309. if (!is_array($destination)) {
  20310. exit;
  20311. }
  20312. chdir($currentDirectory);
  20313. foreach ($source as $dir => $value) {
  20314. foreach ($value as $file => $hash) {
  20315. if (isset($destination[$dir][$file])) {
  20316. if ($hash !== $destination[$dir][$file]) {
  20317. $this->changed['changed'][] = $dir.'/'.$file;
  20318. }
  20319. } else {
  20320. $this->changed['removed'][] = $dir.'/'.$file;
  20321. }
  20322. }
  20323. }
  20324. foreach ($destination as $dir => $value) {
  20325. foreach ($value as $file => $hash) {
  20326. if (!isset($source[$dir][$file])) {
  20327. $this->changed['added'][] = $dir.'/'.$file;
  20328. }
  20329. }
  20330. }
  20331. }
  20332. private function doTree($dir, &$array)
  20333. {
  20334. if ($dh = opendir($dir)) {
  20335. while ($file = readdir($dh)) {
  20336. if ($file !== '.' && $file !== '..') {
  20337. if (is_link($dir.'/'.$file)) {
  20338. $array[$dir][$file] = readlink($dir.'/'.$file);
  20339. } elseif (is_dir($dir.'/'.$file)) {
  20340. if (!count($array)) {
  20341. $array[0] = 'Temp';
  20342. }
  20343. if (!$this->doTree($dir.'/'.$file, $array)) {
  20344. return false;
  20345. }
  20346. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  20347. $array[$dir][$file] = md5_file($dir.'/'.$file);
  20348. }
  20349. }
  20350. }
  20351. if (count($array) > 1 && isset($array['0'])) {
  20352. unset($array['0']);
  20353. }
  20354. return $array;
  20355. }
  20356. return false;
  20357. }
  20358. }
  20359. <?php
  20360. namespace Composer\Package;
  20361. class CompleteAliasPackage extends AliasPackage implements CompletePackageInterface
  20362. {
  20363. protected $aliasOf;
  20364. public function __construct(CompletePackage $aliasOf, $version, $prettyVersion)
  20365. {
  20366. parent::__construct($aliasOf, $version, $prettyVersion);
  20367. }
  20368. public function getAliasOf()
  20369. {
  20370. return $this->aliasOf;
  20371. }
  20372. public function getScripts()
  20373. {
  20374. return $this->aliasOf->getScripts();
  20375. }
  20376. public function setScripts(array $scripts)
  20377. {
  20378. $this->aliasOf->setScripts($scripts);
  20379. }
  20380. public function getRepositories()
  20381. {
  20382. return $this->aliasOf->getRepositories();
  20383. }
  20384. public function setRepositories(array $repositories)
  20385. {
  20386. $this->aliasOf->setRepositories($repositories);
  20387. }
  20388. public function getLicense()
  20389. {
  20390. return $this->aliasOf->getLicense();
  20391. }
  20392. public function setLicense(array $license)
  20393. {
  20394. $this->aliasOf->setLicense($license);
  20395. }
  20396. public function getKeywords()
  20397. {
  20398. return $this->aliasOf->getKeywords();
  20399. }
  20400. public function setKeywords(array $keywords)
  20401. {
  20402. $this->aliasOf->setKeywords($keywords);
  20403. }
  20404. public function getDescription()
  20405. {
  20406. return $this->aliasOf->getDescription();
  20407. }
  20408. public function setDescription($description)
  20409. {
  20410. $this->aliasOf->setDescription($description);
  20411. }
  20412. public function getHomepage()
  20413. {
  20414. return $this->aliasOf->getHomepage();
  20415. }
  20416. public function setHomepage($homepage)
  20417. {
  20418. $this->aliasOf->setHomepage($homepage);
  20419. }
  20420. public function getAuthors()
  20421. {
  20422. return $this->aliasOf->getAuthors();
  20423. }
  20424. public function setAuthors(array $authors)
  20425. {
  20426. $this->aliasOf->setAuthors($authors);
  20427. }
  20428. public function getSupport()
  20429. {
  20430. return $this->aliasOf->getSupport();
  20431. }
  20432. public function setSupport(array $support)
  20433. {
  20434. $this->aliasOf->setSupport($support);
  20435. }
  20436. public function getFunding()
  20437. {
  20438. return $this->aliasOf->getFunding();
  20439. }
  20440. public function setFunding(array $funding)
  20441. {
  20442. $this->aliasOf->setFunding($funding);
  20443. }
  20444. public function isAbandoned()
  20445. {
  20446. return $this->aliasOf->isAbandoned();
  20447. }
  20448. public function getReplacementPackage()
  20449. {
  20450. return $this->aliasOf->getReplacementPackage();
  20451. }
  20452. public function setAbandoned($abandoned)
  20453. {
  20454. $this->aliasOf->setAbandoned($abandoned);
  20455. }
  20456. public function getArchiveName()
  20457. {
  20458. return $this->aliasOf->getArchiveName();
  20459. }
  20460. public function setArchiveName($name)
  20461. {
  20462. $this->aliasOf->setArchiveName($name);
  20463. }
  20464. public function getArchiveExcludes()
  20465. {
  20466. return $this->aliasOf->getArchiveExcludes();
  20467. }
  20468. public function setArchiveExcludes(array $excludes)
  20469. {
  20470. $this->aliasOf->setArchiveExcludes($excludes);
  20471. }
  20472. }
  20473. <?php
  20474. namespace Composer\Package;
  20475. class CompletePackage extends Package implements CompletePackageInterface
  20476. {
  20477. protected $repositories = array();
  20478. protected $license = array();
  20479. protected $keywords = array();
  20480. protected $authors = array();
  20481. protected $description = null;
  20482. protected $homepage = null;
  20483. protected $scripts = array();
  20484. protected $support = array();
  20485. protected $funding = array();
  20486. protected $abandoned = false;
  20487. protected $archiveName = null;
  20488. protected $archiveExcludes = array();
  20489. public function setScripts(array $scripts)
  20490. {
  20491. $this->scripts = $scripts;
  20492. }
  20493. public function getScripts()
  20494. {
  20495. return $this->scripts;
  20496. }
  20497. public function setRepositories(array $repositories)
  20498. {
  20499. $this->repositories = $repositories;
  20500. }
  20501. public function getRepositories()
  20502. {
  20503. return $this->repositories;
  20504. }
  20505. public function setLicense(array $license)
  20506. {
  20507. $this->license = $license;
  20508. }
  20509. public function getLicense()
  20510. {
  20511. return $this->license;
  20512. }
  20513. public function setKeywords(array $keywords)
  20514. {
  20515. $this->keywords = $keywords;
  20516. }
  20517. public function getKeywords()
  20518. {
  20519. return $this->keywords;
  20520. }
  20521. public function setAuthors(array $authors)
  20522. {
  20523. $this->authors = $authors;
  20524. }
  20525. public function getAuthors()
  20526. {
  20527. return $this->authors;
  20528. }
  20529. public function setDescription($description)
  20530. {
  20531. $this->description = $description;
  20532. }
  20533. public function getDescription()
  20534. {
  20535. return $this->description;
  20536. }
  20537. public function setHomepage($homepage)
  20538. {
  20539. $this->homepage = $homepage;
  20540. }
  20541. public function getHomepage()
  20542. {
  20543. return $this->homepage;
  20544. }
  20545. public function setSupport(array $support)
  20546. {
  20547. $this->support = $support;
  20548. }
  20549. public function getSupport()
  20550. {
  20551. return $this->support;
  20552. }
  20553. public function setFunding(array $funding)
  20554. {
  20555. $this->funding = $funding;
  20556. }
  20557. public function getFunding()
  20558. {
  20559. return $this->funding;
  20560. }
  20561. public function isAbandoned()
  20562. {
  20563. return (bool) $this->abandoned;
  20564. }
  20565. public function setAbandoned($abandoned)
  20566. {
  20567. $this->abandoned = $abandoned;
  20568. }
  20569. public function getReplacementPackage()
  20570. {
  20571. return \is_string($this->abandoned) ? $this->abandoned : null;
  20572. }
  20573. public function setArchiveName($name)
  20574. {
  20575. $this->archiveName = $name;
  20576. }
  20577. public function getArchiveName()
  20578. {
  20579. return $this->archiveName;
  20580. }
  20581. public function setArchiveExcludes(array $excludes)
  20582. {
  20583. $this->archiveExcludes = $excludes;
  20584. }
  20585. public function getArchiveExcludes()
  20586. {
  20587. return $this->archiveExcludes;
  20588. }
  20589. }
  20590. <?php
  20591. namespace Composer\Package;
  20592. interface CompletePackageInterface extends PackageInterface
  20593. {
  20594. public function getScripts();
  20595. public function setScripts(array $scripts);
  20596. public function getRepositories();
  20597. public function setRepositories(array $repositories);
  20598. public function getLicense();
  20599. public function setLicense(array $license);
  20600. public function getKeywords();
  20601. public function setKeywords(array $keywords);
  20602. public function getDescription();
  20603. public function setDescription($description);
  20604. public function getHomepage();
  20605. public function setHomepage($homepage);
  20606. public function getAuthors();
  20607. public function setAuthors(array $authors);
  20608. public function getSupport();
  20609. public function setSupport(array $support);
  20610. public function getFunding();
  20611. public function setFunding(array $funding);
  20612. public function isAbandoned();
  20613. public function getReplacementPackage();
  20614. public function setAbandoned($abandoned);
  20615. public function getArchiveName();
  20616. public function setArchiveName($name);
  20617. public function getArchiveExcludes();
  20618. public function setArchiveExcludes(array $excludes);
  20619. }
  20620. <?php
  20621. namespace Composer\Package\Dumper;
  20622. use Composer\Package\BasePackage;
  20623. use Composer\Package\PackageInterface;
  20624. use Composer\Package\CompletePackageInterface;
  20625. use Composer\Package\RootPackageInterface;
  20626. class ArrayDumper
  20627. {
  20628. public function dump(PackageInterface $package)
  20629. {
  20630. $keys = array(
  20631. 'binaries' => 'bin',
  20632. 'type',
  20633. 'extra',
  20634. 'installationSource' => 'installation-source',
  20635. 'autoload',
  20636. 'devAutoload' => 'autoload-dev',
  20637. 'notificationUrl' => 'notification-url',
  20638. 'includePaths' => 'include-path',
  20639. );
  20640. $data = array();
  20641. $data['name'] = $package->getPrettyName();
  20642. $data['version'] = $package->getPrettyVersion();
  20643. $data['version_normalized'] = $package->getVersion();
  20644. if ($package->getTargetDir()) {
  20645. $data['target-dir'] = $package->getTargetDir();
  20646. }
  20647. if ($package->getSourceType()) {
  20648. $data['source']['type'] = $package->getSourceType();
  20649. $data['source']['url'] = $package->getSourceUrl();
  20650. if (null !== ($value = $package->getSourceReference())) {
  20651. $data['source']['reference'] = $value;
  20652. }
  20653. if ($mirrors = $package->getSourceMirrors()) {
  20654. $data['source']['mirrors'] = $mirrors;
  20655. }
  20656. }
  20657. if ($package->getDistType()) {
  20658. $data['dist']['type'] = $package->getDistType();
  20659. $data['dist']['url'] = $package->getDistUrl();
  20660. if (null !== ($value = $package->getDistReference())) {
  20661. $data['dist']['reference'] = $value;
  20662. }
  20663. if (null !== ($value = $package->getDistSha1Checksum())) {
  20664. $data['dist']['shasum'] = $value;
  20665. }
  20666. if ($mirrors = $package->getDistMirrors()) {
  20667. $data['dist']['mirrors'] = $mirrors;
  20668. }
  20669. }
  20670. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  20671. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  20672. foreach ($links as $link) {
  20673. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  20674. }
  20675. ksort($data[$type]);
  20676. }
  20677. }
  20678. if ($packages = $package->getSuggests()) {
  20679. ksort($packages);
  20680. $data['suggest'] = $packages;
  20681. }
  20682. if ($package->getReleaseDate()) {
  20683. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  20684. }
  20685. if ($package->isDefaultBranch()) {
  20686. $data['default-branch'] = true;
  20687. }
  20688. $data = $this->dumpValues($package, $keys, $data);
  20689. if ($package instanceof CompletePackageInterface) {
  20690. if ($package->getArchiveName()) {
  20691. $data['archive']['name'] = $package->getArchiveName();
  20692. }
  20693. if ($package->getArchiveExcludes()) {
  20694. $data['archive']['exclude'] = $package->getArchiveExcludes();
  20695. }
  20696. $keys = array(
  20697. 'scripts',
  20698. 'license',
  20699. 'authors',
  20700. 'description',
  20701. 'homepage',
  20702. 'keywords',
  20703. 'repositories',
  20704. 'support',
  20705. 'funding',
  20706. );
  20707. $data = $this->dumpValues($package, $keys, $data);
  20708. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  20709. sort($data['keywords']);
  20710. }
  20711. if ($package->isAbandoned()) {
  20712. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  20713. }
  20714. }
  20715. if ($package instanceof RootPackageInterface) {
  20716. $minimumStability = $package->getMinimumStability();
  20717. if ($minimumStability) {
  20718. $data['minimum-stability'] = $minimumStability;
  20719. }
  20720. }
  20721. if (\count($package->getTransportOptions()) > 0) {
  20722. $data['transport-options'] = $package->getTransportOptions();
  20723. }
  20724. return $data;
  20725. }
  20726. private function dumpValues(PackageInterface $package, array $keys, array $data)
  20727. {
  20728. foreach ($keys as $method => $key) {
  20729. if (is_numeric($method)) {
  20730. $method = $key;
  20731. }
  20732. $getter = 'get'.ucfirst($method);
  20733. $value = $package->$getter();
  20734. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  20735. $data[$key] = $value;
  20736. }
  20737. }
  20738. return $data;
  20739. }
  20740. }
  20741. <?php
  20742. namespace Composer\Package;
  20743. use Composer\Semver\Constraint\ConstraintInterface;
  20744. class Link
  20745. {
  20746. const TYPE_REQUIRE = 'requires';
  20747. const TYPE_DEV_REQUIRE = 'devRequires';
  20748. const TYPE_PROVIDE = 'provides';
  20749. const TYPE_CONFLICT = 'conflicts';
  20750. const TYPE_REPLACE = 'replaces';
  20751. const TYPE_DOES_NOT_REQUIRE = 'does not require';
  20752. const TYPE_UNKNOWN = 'relates to';
  20753. public static $TYPES = array(
  20754. self::TYPE_REQUIRE,
  20755. self::TYPE_DEV_REQUIRE,
  20756. self::TYPE_PROVIDE,
  20757. self::TYPE_CONFLICT,
  20758. self::TYPE_REPLACE,
  20759. );
  20760. protected $source;
  20761. protected $target;
  20762. protected $constraint;
  20763. protected $description;
  20764. protected $prettyConstraint;
  20765. public function __construct(
  20766. $source,
  20767. $target,
  20768. ConstraintInterface $constraint,
  20769. $description = self::TYPE_UNKNOWN,
  20770. $prettyConstraint = null
  20771. ) {
  20772. $this->source = strtolower($source);
  20773. $this->target = strtolower($target);
  20774. $this->constraint = $constraint;
  20775. $this->description = self::TYPE_DEV_REQUIRE === $description ? 'requires (for development)' : $description;
  20776. $this->prettyConstraint = $prettyConstraint;
  20777. }
  20778. public function getDescription()
  20779. {
  20780. return $this->description;
  20781. }
  20782. public function getSource()
  20783. {
  20784. return $this->source;
  20785. }
  20786. public function getTarget()
  20787. {
  20788. return $this->target;
  20789. }
  20790. public function getConstraint()
  20791. {
  20792. return $this->constraint;
  20793. }
  20794. public function getPrettyConstraint()
  20795. {
  20796. if (null === $this->prettyConstraint) {
  20797. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  20798. }
  20799. return $this->prettyConstraint;
  20800. }
  20801. public function __toString()
  20802. {
  20803. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  20804. }
  20805. public function getPrettyString(PackageInterface $sourcePackage)
  20806. {
  20807. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.' '.$this->constraint->getPrettyString();
  20808. }
  20809. }
  20810. <?php
  20811. namespace Composer\Package\Loader;
  20812. use Composer\Package\BasePackage;
  20813. use Composer\Package\CompleteAliasPackage;
  20814. use Composer\Package\CompletePackage;
  20815. use Composer\Package\RootPackage;
  20816. use Composer\Package\PackageInterface;
  20817. use Composer\Package\CompletePackageInterface;
  20818. use Composer\Package\Link;
  20819. use Composer\Package\RootAliasPackage;
  20820. use Composer\Package\Version\VersionParser;
  20821. class ArrayLoader implements LoaderInterface
  20822. {
  20823. protected $versionParser;
  20824. protected $loadOptions;
  20825. public function __construct(VersionParser $parser = null, $loadOptions = false)
  20826. {
  20827. if (!$parser) {
  20828. $parser = new VersionParser;
  20829. }
  20830. $this->versionParser = $parser;
  20831. $this->loadOptions = $loadOptions;
  20832. }
  20833. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  20834. {
  20835. if ($class !== 'Composer\Package\CompletePackage' && $class !== 'Composer\Package\RootPackage') {
  20836. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  20837. }
  20838. $package = $this->createObject($config, $class);
  20839. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  20840. if (isset($config[$type])) {
  20841. $method = 'set'.ucfirst($opts['method']);
  20842. $package->{$method}(
  20843. $this->parseLinks(
  20844. $package->getName(),
  20845. $package->getPrettyVersion(),
  20846. $opts['method'],
  20847. $config[$type]
  20848. )
  20849. );
  20850. }
  20851. }
  20852. $package = $this->configureObject($package, $config);
  20853. return $package;
  20854. }
  20855. public function loadPackages(array $versions)
  20856. {
  20857. $packages = array();
  20858. $linkCache = array();
  20859. foreach ($versions as $version) {
  20860. $package = $this->createObject($version, 'Composer\Package\CompletePackage');
  20861. $this->configureCachedLinks($linkCache, $package, $version);
  20862. $package = $this->configureObject($package, $version);
  20863. $packages[] = $package;
  20864. }
  20865. return $packages;
  20866. }
  20867. private function createObject(array $config, $class)
  20868. {
  20869. if (!isset($config['name'])) {
  20870. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  20871. }
  20872. if (!isset($config['version'])) {
  20873. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  20874. }
  20875. if (isset($config['version_normalized'])) {
  20876. $version = $config['version_normalized'];
  20877. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  20878. $version = $this->versionParser->normalize($config['version']);
  20879. }
  20880. } else {
  20881. $version = $this->versionParser->normalize($config['version']);
  20882. }
  20883. return new $class($config['name'], $version, $config['version']);
  20884. }
  20885. private function configureObject(PackageInterface $package, array $config)
  20886. {
  20887. if (!$package instanceof CompletePackage) {
  20888. throw new \LogicException('ArrayLoader expects instances of the Composer\Package\CompletePackage class to function correctly');
  20889. }
  20890. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  20891. if (isset($config['target-dir'])) {
  20892. $package->setTargetDir($config['target-dir']);
  20893. }
  20894. if (isset($config['extra']) && \is_array($config['extra'])) {
  20895. $package->setExtra($config['extra']);
  20896. }
  20897. if (isset($config['bin'])) {
  20898. if (!\is_array($config['bin'])) {
  20899. $config['bin'] = array($config['bin']);
  20900. }
  20901. foreach ($config['bin'] as $key => $bin) {
  20902. $config['bin'][$key] = ltrim($bin, '/');
  20903. }
  20904. $package->setBinaries($config['bin']);
  20905. }
  20906. if (isset($config['installation-source'])) {
  20907. $package->setInstallationSource($config['installation-source']);
  20908. }
  20909. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  20910. $package->setIsDefaultBranch(true);
  20911. }
  20912. if (isset($config['source'])) {
  20913. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  20914. throw new \UnexpectedValueException(sprintf(
  20915. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  20916. $config['name'],
  20917. json_encode($config['source'])
  20918. ));
  20919. }
  20920. $package->setSourceType($config['source']['type']);
  20921. $package->setSourceUrl($config['source']['url']);
  20922. $package->setSourceReference(isset($config['source']['reference']) ? $config['source']['reference'] : null);
  20923. if (isset($config['source']['mirrors'])) {
  20924. $package->setSourceMirrors($config['source']['mirrors']);
  20925. }
  20926. }
  20927. if (isset($config['dist'])) {
  20928. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  20929. throw new \UnexpectedValueException(sprintf(
  20930. "Package %s's dist key should be specified as ".
  20931. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  20932. $config['name'],
  20933. json_encode($config['dist'])
  20934. ));
  20935. }
  20936. $package->setDistType($config['dist']['type']);
  20937. $package->setDistUrl($config['dist']['url']);
  20938. $package->setDistReference(isset($config['dist']['reference']) ? $config['dist']['reference'] : null);
  20939. $package->setDistSha1Checksum(isset($config['dist']['shasum']) ? $config['dist']['shasum'] : null);
  20940. if (isset($config['dist']['mirrors'])) {
  20941. $package->setDistMirrors($config['dist']['mirrors']);
  20942. }
  20943. }
  20944. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  20945. foreach ($config['suggest'] as $target => $reason) {
  20946. if ('self.version' === trim($reason)) {
  20947. $config['suggest'][$target] = $package->getPrettyVersion();
  20948. }
  20949. }
  20950. $package->setSuggests($config['suggest']);
  20951. }
  20952. if (isset($config['autoload'])) {
  20953. $package->setAutoload($config['autoload']);
  20954. }
  20955. if (isset($config['autoload-dev'])) {
  20956. $package->setDevAutoload($config['autoload-dev']);
  20957. }
  20958. if (isset($config['include-path'])) {
  20959. $package->setIncludePaths($config['include-path']);
  20960. }
  20961. if (!empty($config['time'])) {
  20962. $time = preg_match('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  20963. try {
  20964. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  20965. $package->setReleaseDate($date);
  20966. } catch (\Exception $e) {
  20967. }
  20968. }
  20969. if (!empty($config['notification-url'])) {
  20970. $package->setNotificationUrl($config['notification-url']);
  20971. }
  20972. if ($package instanceof CompletePackageInterface) {
  20973. if (!empty($config['archive']['name'])) {
  20974. $package->setArchiveName($config['archive']['name']);
  20975. }
  20976. if (!empty($config['archive']['exclude'])) {
  20977. $package->setArchiveExcludes($config['archive']['exclude']);
  20978. }
  20979. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  20980. foreach ($config['scripts'] as $event => $listeners) {
  20981. $config['scripts'][$event] = (array) $listeners;
  20982. }
  20983. if (isset($config['scripts']['composer'])) {
  20984. trigger_error('The `composer` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  20985. }
  20986. $package->setScripts($config['scripts']);
  20987. }
  20988. if (!empty($config['description']) && \is_string($config['description'])) {
  20989. $package->setDescription($config['description']);
  20990. }
  20991. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  20992. $package->setHomepage($config['homepage']);
  20993. }
  20994. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  20995. $package->setKeywords($config['keywords']);
  20996. }
  20997. if (!empty($config['license'])) {
  20998. $package->setLicense(\is_array($config['license']) ? $config['license'] : array($config['license']));
  20999. }
  21000. if (!empty($config['authors']) && \is_array($config['authors'])) {
  21001. $package->setAuthors($config['authors']);
  21002. }
  21003. if (isset($config['support'])) {
  21004. $package->setSupport($config['support']);
  21005. }
  21006. if (!empty($config['funding']) && \is_array($config['funding'])) {
  21007. $package->setFunding($config['funding']);
  21008. }
  21009. if (isset($config['abandoned'])) {
  21010. $package->setAbandoned($config['abandoned']);
  21011. }
  21012. }
  21013. if ($this->loadOptions && isset($config['transport-options'])) {
  21014. $package->setTransportOptions($config['transport-options']);
  21015. }
  21016. if ($aliasNormalized = $this->getBranchAlias($config)) {
  21017. $prettyAlias = preg_replace('{(\.9{7})+}', '.x', $aliasNormalized);
  21018. if ($package instanceof RootPackage) {
  21019. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  21020. }
  21021. return new CompleteAliasPackage($package, $aliasNormalized, $prettyAlias);
  21022. }
  21023. return $package;
  21024. }
  21025. private function configureCachedLinks(&$linkCache, $package, array $config)
  21026. {
  21027. $name = $package->getName();
  21028. $prettyVersion = $package->getPrettyVersion();
  21029. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  21030. if (isset($config[$type])) {
  21031. $method = 'set'.ucfirst($opts['method']);
  21032. $links = array();
  21033. foreach ($config[$type] as $prettyTarget => $constraint) {
  21034. $target = strtolower($prettyTarget);
  21035. if ($constraint === 'self.version') {
  21036. $links[$target] = $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint);
  21037. } else {
  21038. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  21039. $linkCache[$name][$type][$target][$constraint] = array($target, $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint));
  21040. }
  21041. list($target, $link) = $linkCache[$name][$type][$target][$constraint];
  21042. $links[$target] = $link;
  21043. }
  21044. }
  21045. $package->{$method}($links);
  21046. }
  21047. }
  21048. }
  21049. public function parseLinks($source, $sourceVersion, $description, $links)
  21050. {
  21051. $res = array();
  21052. foreach ($links as $target => $constraint) {
  21053. $res[strtolower($target)] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  21054. }
  21055. return $res;
  21056. }
  21057. private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint)
  21058. {
  21059. if (!\is_string($prettyConstraint)) {
  21060. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  21061. }
  21062. if ('self.version' === $prettyConstraint) {
  21063. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  21064. } else {
  21065. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  21066. }
  21067. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  21068. }
  21069. public function getBranchAlias(array $config)
  21070. {
  21071. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  21072. return null;
  21073. }
  21074. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  21075. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  21076. if ('-dev' !== substr($targetBranch, -4)) {
  21077. continue;
  21078. }
  21079. if ($targetBranch === VersionParser::DEFAULT_BRANCH_ALIAS) {
  21080. $validatedTargetBranch = VersionParser::DEFAULT_BRANCH_ALIAS;
  21081. } else {
  21082. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  21083. }
  21084. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  21085. continue;
  21086. }
  21087. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  21088. continue;
  21089. }
  21090. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  21091. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  21092. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  21093. ) {
  21094. continue;
  21095. }
  21096. return $validatedTargetBranch;
  21097. }
  21098. }
  21099. if (
  21100. isset($config['default-branch'])
  21101. && $config['default-branch'] === true
  21102. && false === $this->versionParser->parseNumericAliasPrefix($config['version'])
  21103. ) {
  21104. return VersionParser::DEFAULT_BRANCH_ALIAS;
  21105. }
  21106. return null;
  21107. }
  21108. }
  21109. <?php
  21110. namespace Composer\Package\Loader;
  21111. class InvalidPackageException extends \Exception
  21112. {
  21113. private $errors;
  21114. private $warnings;
  21115. private $data;
  21116. public function __construct(array $errors, array $warnings, array $data)
  21117. {
  21118. $this->errors = $errors;
  21119. $this->warnings = $warnings;
  21120. $this->data = $data;
  21121. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  21122. }
  21123. public function getData()
  21124. {
  21125. return $this->data;
  21126. }
  21127. public function getErrors()
  21128. {
  21129. return $this->errors;
  21130. }
  21131. public function getWarnings()
  21132. {
  21133. return $this->warnings;
  21134. }
  21135. }
  21136. <?php
  21137. namespace Composer\Package\Loader;
  21138. use Composer\Json\JsonFile;
  21139. use Composer\Package\CompletePackage;
  21140. use Composer\Package\CompleteAliasPackage;
  21141. class JsonLoader
  21142. {
  21143. private $loader;
  21144. public function __construct(LoaderInterface $loader)
  21145. {
  21146. $this->loader = $loader;
  21147. }
  21148. public function load($json)
  21149. {
  21150. if ($json instanceof JsonFile) {
  21151. $config = $json->read();
  21152. } elseif (file_exists($json)) {
  21153. $config = JsonFile::parseJson(file_get_contents($json), $json);
  21154. } elseif (is_string($json)) {
  21155. $config = JsonFile::parseJson($json);
  21156. } else {
  21157. throw new \InvalidArgumentException(sprintf(
  21158. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  21159. gettype($json)
  21160. ));
  21161. }
  21162. return $this->loader->load($config);
  21163. }
  21164. }
  21165. <?php
  21166. namespace Composer\Package\Loader;
  21167. use Composer\Package\CompletePackageInterface;
  21168. use Composer\Package\CompletePackage;
  21169. use Composer\Package\CompleteAliasPackage;
  21170. use Composer\Package\RootAliasPackage;
  21171. use Composer\Package\RootPackage;
  21172. interface LoaderInterface
  21173. {
  21174. public function load(array $config, $class = 'Composer\Package\CompletePackage');
  21175. }
  21176. <?php
  21177. namespace Composer\Package\Loader;
  21178. use Composer\Package\BasePackage;
  21179. use Composer\Config;
  21180. use Composer\IO\IOInterface;
  21181. use Composer\Package\RootAliasPackage;
  21182. use Composer\Repository\RepositoryFactory;
  21183. use Composer\Package\Version\VersionGuesser;
  21184. use Composer\Package\Version\VersionParser;
  21185. use Composer\Package\RootPackage;
  21186. use Composer\Repository\RepositoryManager;
  21187. use Composer\Util\ProcessExecutor;
  21188. class RootPackageLoader extends ArrayLoader
  21189. {
  21190. private $manager;
  21191. private $config;
  21192. private $versionGuesser;
  21193. public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null)
  21194. {
  21195. parent::__construct($parser);
  21196. $this->manager = $manager;
  21197. $this->config = $config;
  21198. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
  21199. }
  21200. public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
  21201. {
  21202. if ($class !== 'Composer\Package\RootPackage') {
  21203. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  21204. }
  21205. if (!isset($config['name'])) {
  21206. $config['name'] = '__root__';
  21207. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  21208. throw new \RuntimeException('Your package name '.$err);
  21209. }
  21210. $autoVersioned = false;
  21211. if (!isset($config['version'])) {
  21212. $commit = null;
  21213. if (getenv('COMPOSER_ROOT_VERSION')) {
  21214. $config['version'] = getenv('COMPOSER_ROOT_VERSION');
  21215. } else {
  21216. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
  21217. if ($versionData) {
  21218. $config['version'] = $versionData['pretty_version'];
  21219. $config['version_normalized'] = $versionData['version'];
  21220. $commit = $versionData['commit'];
  21221. }
  21222. }
  21223. if (!isset($config['version'])) {
  21224. $config['version'] = '1.0.0';
  21225. $autoVersioned = true;
  21226. }
  21227. if ($commit) {
  21228. $config['source'] = array(
  21229. 'type' => '',
  21230. 'url' => '',
  21231. 'reference' => $commit,
  21232. );
  21233. $config['dist'] = array(
  21234. 'type' => '',
  21235. 'url' => '',
  21236. 'reference' => $commit,
  21237. );
  21238. }
  21239. }
  21240. $package = parent::load($config, $class);
  21241. if ($package instanceof RootAliasPackage) {
  21242. $realPackage = $package->getAliasOf();
  21243. } else {
  21244. $realPackage = $package;
  21245. }
  21246. if (!$realPackage instanceof RootPackage) {
  21247. throw new \LogicException('Expecting a Composer\Package\RootPackage at this point');
  21248. }
  21249. if ($autoVersioned) {
  21250. $realPackage->replaceVersion($realPackage->getVersion(), RootPackage::DEFAULT_PRETTY_VERSION);
  21251. }
  21252. if (isset($config['minimum-stability'])) {
  21253. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  21254. }
  21255. $aliases = array();
  21256. $stabilityFlags = array();
  21257. $references = array();
  21258. foreach (array('require', 'require-dev') as $linkType) {
  21259. if (isset($config[$linkType])) {
  21260. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  21261. $method = 'get'.ucfirst($linkInfo['method']);
  21262. $links = array();
  21263. foreach ($realPackage->$method() as $link) {
  21264. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  21265. }
  21266. $aliases = $this->extractAliases($links, $aliases);
  21267. $stabilityFlags = self::extractStabilityFlags($links, $realPackage->getMinimumStability(), $stabilityFlags);
  21268. $references = self::extractReferences($links, $references);
  21269. if (isset($links[$config['name']])) {
  21270. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  21271. 'Did you accidentally name your root package after an external package?', $config['name']));
  21272. }
  21273. }
  21274. }
  21275. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  21276. if (isset($config[$linkType])) {
  21277. foreach ($config[$linkType] as $linkName => $constraint) {
  21278. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  21279. throw new \RuntimeException($linkType.'.'.$err);
  21280. }
  21281. }
  21282. }
  21283. }
  21284. $realPackage->setAliases($aliases);
  21285. $realPackage->setStabilityFlags($stabilityFlags);
  21286. $realPackage->setReferences($references);
  21287. if (isset($config['prefer-stable'])) {
  21288. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  21289. }
  21290. if (isset($config['config'])) {
  21291. $realPackage->setConfig($config['config']);
  21292. }
  21293. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  21294. foreach ($repos as $repo) {
  21295. $this->manager->addRepository($repo);
  21296. }
  21297. $realPackage->setRepositories($this->config->getRepositories());
  21298. return $package;
  21299. }
  21300. private function extractAliases(array $requires, array $aliases)
  21301. {
  21302. foreach ($requires as $reqName => $reqVersion) {
  21303. if (preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
  21304. $aliases[] = array(
  21305. 'package' => strtolower($reqName),
  21306. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  21307. 'alias' => $match[2],
  21308. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  21309. );
  21310. } elseif (strpos($reqVersion, ' as ') !== false) {
  21311. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  21312. }
  21313. }
  21314. return $aliases;
  21315. }
  21316. public static function extractStabilityFlags(array $requires, $minimumStability, array $stabilityFlags)
  21317. {
  21318. $stabilities = BasePackage::$stabilities;
  21319. $minimumStability = $stabilities[$minimumStability];
  21320. foreach ($requires as $reqName => $reqVersion) {
  21321. $constraints = array();
  21322. $orSplit = preg_split('{\s*\|\|?\s*}', trim($reqVersion));
  21323. foreach ($orSplit as $orConstraint) {
  21324. $andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  21325. foreach ($andSplit as $andConstraint) {
  21326. $constraints[] = $andConstraint;
  21327. }
  21328. }
  21329. $match = false;
  21330. foreach ($constraints as $constraint) {
  21331. if (preg_match('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  21332. $name = strtolower($reqName);
  21333. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  21334. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  21335. continue;
  21336. }
  21337. $stabilityFlags[$name] = $stability;
  21338. $match = true;
  21339. }
  21340. }
  21341. if ($match) {
  21342. continue;
  21343. }
  21344. foreach ($constraints as $constraint) {
  21345. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  21346. if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  21347. $name = strtolower($reqName);
  21348. $stability = $stabilities[$stabilityName];
  21349. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  21350. continue;
  21351. }
  21352. $stabilityFlags[$name] = $stability;
  21353. }
  21354. }
  21355. }
  21356. return $stabilityFlags;
  21357. }
  21358. public static function extractReferences(array $requires, array $references)
  21359. {
  21360. foreach ($requires as $reqName => $reqVersion) {
  21361. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  21362. if (preg_match('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  21363. $name = strtolower($reqName);
  21364. $references[$name] = $match[1];
  21365. }
  21366. }
  21367. return $references;
  21368. }
  21369. }
  21370. <?php
  21371. namespace Composer\Package\Loader;
  21372. use Composer\Package\BasePackage;
  21373. use Composer\Semver\Constraint\Constraint;
  21374. use Composer\Package\Version\VersionParser;
  21375. use Composer\Repository\PlatformRepository;
  21376. use Composer\Spdx\SpdxLicenses;
  21377. class ValidatingArrayLoader implements LoaderInterface
  21378. {
  21379. const CHECK_ALL = 3;
  21380. const CHECK_UNBOUND_CONSTRAINTS = 1;
  21381. const CHECK_STRICT_CONSTRAINTS = 2;
  21382. private $loader;
  21383. private $versionParser;
  21384. private $errors;
  21385. private $warnings;
  21386. private $config;
  21387. private $strictName;
  21388. private $flags;
  21389. public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
  21390. {
  21391. $this->loader = $loader;
  21392. $this->versionParser = $parser ?: new VersionParser();
  21393. $this->strictName = $strictName;
  21394. $this->flags = $flags;
  21395. }
  21396. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  21397. {
  21398. $this->errors = array();
  21399. $this->warnings = array();
  21400. $this->config = $config;
  21401. if ($err = self::hasPackageNamingError($config['name'])) {
  21402. $this->warnings[] = 'Deprecation warning: Your package name '.$err.' Make sure you fix this as Composer 2.0 will error.';
  21403. }
  21404. if ($this->strictName) {
  21405. $this->validateRegex('name', '[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*', true);
  21406. } else {
  21407. $this->validateString('name', true);
  21408. }
  21409. if (!empty($this->config['version'])) {
  21410. try {
  21411. $this->versionParser->normalize($this->config['version']);
  21412. } catch (\Exception $e) {
  21413. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  21414. unset($this->config['version']);
  21415. }
  21416. }
  21417. if (!empty($this->config['config']['platform'])) {
  21418. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  21419. try {
  21420. $this->versionParser->normalize($platform);
  21421. } catch (\Exception $e) {
  21422. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  21423. }
  21424. }
  21425. }
  21426. $this->validateRegex('type', '[A-Za-z0-9-]+');
  21427. $this->validateString('target-dir');
  21428. $this->validateArray('extra');
  21429. if (isset($this->config['bin'])) {
  21430. if (is_string($this->config['bin'])) {
  21431. $this->validateString('bin');
  21432. } else {
  21433. $this->validateFlatArray('bin');
  21434. }
  21435. }
  21436. $this->validateArray('scripts');
  21437. $this->validateString('description');
  21438. $this->validateUrl('homepage');
  21439. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  21440. $releaseDate = null;
  21441. $this->validateString('time');
  21442. if (!empty($this->config['time'])) {
  21443. try {
  21444. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  21445. } catch (\Exception $e) {
  21446. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  21447. unset($this->config['time']);
  21448. }
  21449. }
  21450. if (isset($this->config['license']) && (!$releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  21451. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  21452. $licenses = (array) $this->config['license'];
  21453. $licenseValidator = new SpdxLicenses();
  21454. foreach ($licenses as $license) {
  21455. if ('proprietary' === $license) {
  21456. continue;
  21457. }
  21458. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  21459. if (!$licenseValidator->validate($licenseToValidate)) {
  21460. if ($licenseValidator->validate(trim($licenseToValidate))) {
  21461. $this->warnings[] = sprintf(
  21462. 'License %s must not contain extra spaces, make sure to trim it.',
  21463. json_encode($license)
  21464. );
  21465. } else {
  21466. $this->warnings[] = sprintf(
  21467. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  21468. 'If the software is closed-source, you may use "proprietary" as license.',
  21469. json_encode($license)
  21470. );
  21471. }
  21472. }
  21473. }
  21474. }
  21475. }
  21476. if ($this->validateArray('authors') && !empty($this->config['authors'])) {
  21477. foreach ($this->config['authors'] as $key => $author) {
  21478. if (!is_array($author)) {
  21479. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  21480. unset($this->config['authors'][$key]);
  21481. continue;
  21482. }
  21483. foreach (array('homepage', 'email', 'name', 'role') as $authorData) {
  21484. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  21485. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  21486. unset($this->config['authors'][$key][$authorData]);
  21487. }
  21488. }
  21489. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  21490. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  21491. unset($this->config['authors'][$key]['homepage']);
  21492. }
  21493. if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  21494. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  21495. unset($this->config['authors'][$key]['email']);
  21496. }
  21497. if (empty($this->config['authors'][$key])) {
  21498. unset($this->config['authors'][$key]);
  21499. }
  21500. }
  21501. if (empty($this->config['authors'])) {
  21502. unset($this->config['authors']);
  21503. }
  21504. }
  21505. if ($this->validateArray('support') && !empty($this->config['support'])) {
  21506. foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) {
  21507. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  21508. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  21509. unset($this->config['support'][$key]);
  21510. }
  21511. }
  21512. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  21513. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  21514. unset($this->config['support']['email']);
  21515. }
  21516. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], array('irc', 'ircs'))) {
  21517. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> or ircs:// URL';
  21518. unset($this->config['support']['irc']);
  21519. }
  21520. foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) {
  21521. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  21522. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  21523. unset($this->config['support'][$key]);
  21524. }
  21525. }
  21526. if (empty($this->config['support'])) {
  21527. unset($this->config['support']);
  21528. }
  21529. }
  21530. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  21531. foreach ($this->config['funding'] as $key => $fundingOption) {
  21532. if (!is_array($fundingOption)) {
  21533. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  21534. unset($this->config['funding'][$key]);
  21535. continue;
  21536. }
  21537. foreach (array('type', 'url') as $fundingData) {
  21538. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  21539. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  21540. unset($this->config['funding'][$key][$fundingData]);
  21541. }
  21542. }
  21543. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  21544. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  21545. unset($this->config['funding'][$key]['url']);
  21546. }
  21547. if (empty($this->config['funding'][$key])) {
  21548. unset($this->config['funding'][$key]);
  21549. }
  21550. }
  21551. if (empty($this->config['funding'])) {
  21552. unset($this->config['funding']);
  21553. }
  21554. }
  21555. $unboundConstraint = new Constraint('=', '10000000-dev');
  21556. $stableConstraint = new Constraint('=', '1.0.0');
  21557. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  21558. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  21559. foreach ($this->config[$linkType] as $package => $constraint) {
  21560. if ($err = self::hasPackageNamingError($package, true)) {
  21561. $this->warnings[] = 'Deprecation warning: '.$linkType.'.'.$err.' Make sure you fix this as Composer 2.0 will error.';
  21562. } elseif (!preg_match('{^[A-Za-z0-9_./-]+$}', $package)) {
  21563. $this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  21564. }
  21565. if (!is_string($constraint)) {
  21566. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  21567. unset($this->config[$linkType][$package]);
  21568. } elseif ('self.version' !== $constraint) {
  21569. try {
  21570. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  21571. } catch (\Exception $e) {
  21572. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  21573. unset($this->config[$linkType][$package]);
  21574. continue;
  21575. }
  21576. if (
  21577. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  21578. && 'require' === $linkType
  21579. && $linkConstraint->matches($unboundConstraint)
  21580. && !PlatformRepository::isPlatformPackage($package)
  21581. ) {
  21582. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  21583. } elseif (
  21584. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  21585. && 'require' === $linkType
  21586. && strpos($linkConstraint, '=') === 0
  21587. && $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
  21588. ) {
  21589. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  21590. }
  21591. }
  21592. }
  21593. }
  21594. }
  21595. if ($this->validateArray('suggest') && !empty($this->config['suggest'])) {
  21596. foreach ($this->config['suggest'] as $package => $description) {
  21597. if (!is_string($description)) {
  21598. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  21599. unset($this->config['suggest'][$package]);
  21600. }
  21601. }
  21602. }
  21603. if ($this->validateString('minimum-stability') && !empty($this->config['minimum-stability'])) {
  21604. if (!isset(BasePackage::$stabilities[strtolower($this->config['minimum-stability'])]) && $this->config['minimum-stability'] !== 'RC') {
  21605. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  21606. unset($this->config['minimum-stability']);
  21607. }
  21608. }
  21609. if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
  21610. $types = array('psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap');
  21611. foreach ($this->config['autoload'] as $type => $typeConfig) {
  21612. if (!in_array($type, $types)) {
  21613. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  21614. unset($this->config['autoload'][$type]);
  21615. }
  21616. if ($type === 'psr-4') {
  21617. foreach ($typeConfig as $namespace => $dirs) {
  21618. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  21619. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  21620. }
  21621. }
  21622. }
  21623. }
  21624. }
  21625. if (!empty($this->config['autoload']['psr-4']) && !empty($this->config['target-dir'])) {
  21626. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  21627. unset($this->config['autoload']['psr-4']);
  21628. }
  21629. foreach (array('source', 'dist') as $srcType) {
  21630. if ($this->validateArray($srcType) && !empty($this->config[$srcType])) {
  21631. if (!isset($this->config[$srcType]['type'])) {
  21632. $this->errors[] = $srcType . '.type : must be present';
  21633. }
  21634. if (!isset($this->config[$srcType]['url'])) {
  21635. $this->errors[] = $srcType . '.url : must be present';
  21636. }
  21637. if ($srcType === 'source' && !isset($this->config[$srcType]['reference'])) {
  21638. $this->errors[] = $srcType . '.reference : must be present';
  21639. }
  21640. if (!is_string($this->config[$srcType]['type'])) {
  21641. $this->errors[] = $srcType . '.type : should be a string, '.gettype($this->config[$srcType]['type']).' given';
  21642. }
  21643. if (!is_string($this->config[$srcType]['url'])) {
  21644. $this->errors[] = $srcType . '.url : should be a string, '.gettype($this->config[$srcType]['url']).' given';
  21645. }
  21646. if (isset($this->config[$srcType]['reference']) && !is_string($this->config[$srcType]['reference']) && !is_int($this->config[$srcType]['reference'])) {
  21647. $this->errors[] = $srcType . '.reference : should be a string or int, '.gettype($this->config[$srcType]['reference']).' given';
  21648. }
  21649. if (isset($this->config[$srcType]['reference']) && preg_match('{^\s*-}', (string) $this->config[$srcType]['reference'])) {
  21650. $this->errors[] = $srcType . '.reference : must not start with a "-", "'.$this->config[$srcType]['reference'].'" given';
  21651. }
  21652. if (preg_match('{^\s*-}', $this->config[$srcType]['url'])) {
  21653. $this->errors[] = $srcType . '.url : must not start with a "-", "'.$this->config[$srcType]['url'].'" given';
  21654. }
  21655. }
  21656. }
  21657. $this->validateFlatArray('include-path');
  21658. $this->validateArray('transport-options');
  21659. if (isset($this->config['extra']['branch-alias'])) {
  21660. if (!is_array($this->config['extra']['branch-alias'])) {
  21661. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  21662. } else {
  21663. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  21664. if (!is_string($targetBranch)) {
  21665. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.json_encode($targetBranch).') must be a string, "'.gettype($targetBranch).'" received.';
  21666. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  21667. continue;
  21668. }
  21669. if ('-dev' !== substr($targetBranch, -4)) {
  21670. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  21671. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  21672. continue;
  21673. }
  21674. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  21675. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  21676. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  21677. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  21678. continue;
  21679. }
  21680. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  21681. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  21682. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  21683. ) {
  21684. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  21685. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  21686. }
  21687. }
  21688. }
  21689. }
  21690. if ($this->errors) {
  21691. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  21692. }
  21693. $package = $this->loader->load($this->config, $class);
  21694. $this->config = array();
  21695. return $package;
  21696. }
  21697. public function getWarnings()
  21698. {
  21699. return $this->warnings;
  21700. }
  21701. public function getErrors()
  21702. {
  21703. return $this->errors;
  21704. }
  21705. public static function hasPackageNamingError($name, $isLink = false)
  21706. {
  21707. if (PlatformRepository::isPlatformPackage($name)) {
  21708. return null;
  21709. }
  21710. if (!preg_match('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
  21711. 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]+)*$".';
  21712. }
  21713. $reservedNames = array('nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9');
  21714. $bits = explode('/', strtolower($name));
  21715. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  21716. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  21717. }
  21718. if (preg_match('{\.json$}', $name)) {
  21719. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  21720. }
  21721. if (preg_match('{[A-Z]}', $name)) {
  21722. if ($isLink) {
  21723. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  21724. }
  21725. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  21726. $suggestName = strtolower($suggestName);
  21727. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  21728. }
  21729. return null;
  21730. }
  21731. private function validateRegex($property, $regex, $mandatory = false)
  21732. {
  21733. if (!$this->validateString($property, $mandatory)) {
  21734. return false;
  21735. }
  21736. if (!preg_match('{^'.$regex.'$}u', $this->config[$property])) {
  21737. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  21738. if ($mandatory) {
  21739. $this->errors[] = $message;
  21740. } else {
  21741. $this->warnings[] = $message;
  21742. }
  21743. unset($this->config[$property]);
  21744. return false;
  21745. }
  21746. return true;
  21747. }
  21748. private function validateString($property, $mandatory = false)
  21749. {
  21750. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  21751. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  21752. unset($this->config[$property]);
  21753. return false;
  21754. }
  21755. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  21756. if ($mandatory) {
  21757. $this->errors[] = $property.' : must be present';
  21758. }
  21759. unset($this->config[$property]);
  21760. return false;
  21761. }
  21762. return true;
  21763. }
  21764. private function validateArray($property, $mandatory = false)
  21765. {
  21766. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  21767. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  21768. unset($this->config[$property]);
  21769. return false;
  21770. }
  21771. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  21772. if ($mandatory) {
  21773. $this->errors[] = $property.' : must be present and contain at least one element';
  21774. }
  21775. unset($this->config[$property]);
  21776. return false;
  21777. }
  21778. return true;
  21779. }
  21780. private function validateFlatArray($property, $regex = null, $mandatory = false)
  21781. {
  21782. if (!$this->validateArray($property, $mandatory)) {
  21783. return false;
  21784. }
  21785. $pass = true;
  21786. foreach ($this->config[$property] as $key => $value) {
  21787. if (!is_string($value) && !is_numeric($value)) {
  21788. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  21789. unset($this->config[$property][$key]);
  21790. $pass = false;
  21791. continue;
  21792. }
  21793. if ($regex && !preg_match('{^'.$regex.'$}u', $value)) {
  21794. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  21795. unset($this->config[$property][$key]);
  21796. $pass = false;
  21797. }
  21798. }
  21799. return $pass;
  21800. }
  21801. private function validateUrl($property, $mandatory = false)
  21802. {
  21803. if (!$this->validateString($property, $mandatory)) {
  21804. return false;
  21805. }
  21806. if (!$this->filterUrl($this->config[$property])) {
  21807. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  21808. unset($this->config[$property]);
  21809. return false;
  21810. }
  21811. return true;
  21812. }
  21813. private function filterUrl($value, array $schemes = array('http', 'https'))
  21814. {
  21815. if ($value === '') {
  21816. return true;
  21817. }
  21818. $bits = parse_url($value);
  21819. if (empty($bits['scheme']) || empty($bits['host'])) {
  21820. return false;
  21821. }
  21822. if (!in_array($bits['scheme'], $schemes, true)) {
  21823. return false;
  21824. }
  21825. return true;
  21826. }
  21827. }
  21828. <?php
  21829. namespace Composer\Package;
  21830. use Composer\Json\JsonFile;
  21831. use Composer\Installer\InstallationManager;
  21832. use Composer\Repository\LockArrayRepository;
  21833. use Composer\Util\ProcessExecutor;
  21834. use Composer\Package\Dumper\ArrayDumper;
  21835. use Composer\Package\Loader\ArrayLoader;
  21836. use Composer\Package\Version\VersionParser;
  21837. use Composer\Plugin\PluginInterface;
  21838. use Composer\Util\Git as GitUtil;
  21839. use Composer\IO\IOInterface;
  21840. use Seld\JsonLint\ParsingException;
  21841. class Locker
  21842. {
  21843. private $lockFile;
  21844. private $installationManager;
  21845. private $hash;
  21846. private $contentHash;
  21847. private $loader;
  21848. private $dumper;
  21849. private $process;
  21850. private $lockDataCache = null;
  21851. private $virtualFileWritten = false;
  21852. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, $composerFileContents, ProcessExecutor $process = null)
  21853. {
  21854. $this->lockFile = $lockFile;
  21855. $this->installationManager = $installationManager;
  21856. $this->hash = md5($composerFileContents);
  21857. $this->contentHash = self::getContentHash($composerFileContents);
  21858. $this->loader = new ArrayLoader(null, true);
  21859. $this->dumper = new ArrayDumper();
  21860. $this->process = $process ?: new ProcessExecutor($io);
  21861. }
  21862. public static function getContentHash($composerFileContents)
  21863. {
  21864. $content = json_decode($composerFileContents, true);
  21865. $relevantKeys = array(
  21866. 'name',
  21867. 'version',
  21868. 'require',
  21869. 'require-dev',
  21870. 'conflict',
  21871. 'replace',
  21872. 'provide',
  21873. 'minimum-stability',
  21874. 'prefer-stable',
  21875. 'repositories',
  21876. 'extra',
  21877. );
  21878. $relevantContent = array();
  21879. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  21880. $relevantContent[$key] = $content[$key];
  21881. }
  21882. if (isset($content['config']['platform'])) {
  21883. $relevantContent['config']['platform'] = $content['config']['platform'];
  21884. }
  21885. ksort($relevantContent);
  21886. return md5(json_encode($relevantContent));
  21887. }
  21888. public function isLocked()
  21889. {
  21890. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  21891. return false;
  21892. }
  21893. $data = $this->getLockData();
  21894. return isset($data['packages']);
  21895. }
  21896. public function isFresh()
  21897. {
  21898. $lock = $this->lockFile->read();
  21899. if (!empty($lock['content-hash'])) {
  21900. return $this->contentHash === $lock['content-hash'];
  21901. }
  21902. if (!empty($lock['hash'])) {
  21903. return $this->hash === $lock['hash'];
  21904. }
  21905. return false;
  21906. }
  21907. public function getLockedRepository($withDevReqs = false)
  21908. {
  21909. $lockData = $this->getLockData();
  21910. $packages = new LockArrayRepository();
  21911. $lockedPackages = $lockData['packages'];
  21912. if ($withDevReqs) {
  21913. if (isset($lockData['packages-dev'])) {
  21914. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  21915. } else {
  21916. 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.');
  21917. }
  21918. }
  21919. if (empty($lockedPackages)) {
  21920. return $packages;
  21921. }
  21922. if (isset($lockedPackages[0]['name'])) {
  21923. $packageByName = array();
  21924. foreach ($lockedPackages as $info) {
  21925. $package = $this->loader->load($info);
  21926. $packages->addPackage($package);
  21927. $packageByName[$package->getName()] = $package;
  21928. if ($package instanceof AliasPackage) {
  21929. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  21930. }
  21931. }
  21932. if (isset($lockData['aliases'])) {
  21933. foreach ($lockData['aliases'] as $alias) {
  21934. if (isset($packageByName[$alias['package']])) {
  21935. $aliasPkg = new CompleteAliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']);
  21936. $aliasPkg->setRootPackageAlias(true);
  21937. $packages->addPackage($aliasPkg);
  21938. }
  21939. }
  21940. }
  21941. return $packages;
  21942. }
  21943. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  21944. }
  21945. public function getDevPackageNames()
  21946. {
  21947. $names = array();
  21948. $lockData = $this->getLockData();
  21949. if (isset($lockData['packages-dev'])) {
  21950. foreach ($lockData['packages-dev'] as $package) {
  21951. $names[] = strtolower($package['name']);
  21952. }
  21953. }
  21954. return $names;
  21955. }
  21956. public function getPlatformRequirements($withDevReqs = false)
  21957. {
  21958. $lockData = $this->getLockData();
  21959. $requirements = array();
  21960. if (!empty($lockData['platform'])) {
  21961. $requirements = $this->loader->parseLinks(
  21962. '__root__',
  21963. '1.0.0',
  21964. Link::TYPE_REQUIRE,
  21965. isset($lockData['platform']) ? $lockData['platform'] : array()
  21966. );
  21967. }
  21968. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  21969. $devRequirements = $this->loader->parseLinks(
  21970. '__root__',
  21971. '1.0.0',
  21972. Link::TYPE_REQUIRE,
  21973. isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
  21974. );
  21975. $requirements = array_merge($requirements, $devRequirements);
  21976. }
  21977. return $requirements;
  21978. }
  21979. public function getMinimumStability()
  21980. {
  21981. $lockData = $this->getLockData();
  21982. return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'stable';
  21983. }
  21984. public function getStabilityFlags()
  21985. {
  21986. $lockData = $this->getLockData();
  21987. return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
  21988. }
  21989. public function getPreferStable()
  21990. {
  21991. $lockData = $this->getLockData();
  21992. return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
  21993. }
  21994. public function getPreferLowest()
  21995. {
  21996. $lockData = $this->getLockData();
  21997. return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
  21998. }
  21999. public function getPlatformOverrides()
  22000. {
  22001. $lockData = $this->getLockData();
  22002. return isset($lockData['platform-overrides']) ? $lockData['platform-overrides'] : array();
  22003. }
  22004. public function getAliases()
  22005. {
  22006. $lockData = $this->getLockData();
  22007. return isset($lockData['aliases']) ? $lockData['aliases'] : array();
  22008. }
  22009. public function getLockData()
  22010. {
  22011. if (null !== $this->lockDataCache) {
  22012. return $this->lockDataCache;
  22013. }
  22014. if (!$this->lockFile->exists()) {
  22015. throw new \LogicException('No lockfile found. Unable to read locked packages');
  22016. }
  22017. return $this->lockDataCache = $this->lockFile->read();
  22018. }
  22019. public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true)
  22020. {
  22021. $aliases = array_map(function ($alias) {
  22022. if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  22023. $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
  22024. }
  22025. return $alias;
  22026. }, $aliases);
  22027. $lock = array(
  22028. '_readme' => array('This file locks the dependencies of your project to a known state',
  22029. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  22030. 'This file is @gener'.'ated automatically', ),
  22031. 'content-hash' => $this->contentHash,
  22032. 'packages' => null,
  22033. 'packages-dev' => null,
  22034. 'aliases' => $aliases,
  22035. 'minimum-stability' => $minimumStability,
  22036. 'stability-flags' => $stabilityFlags,
  22037. 'prefer-stable' => $preferStable,
  22038. 'prefer-lowest' => $preferLowest,
  22039. );
  22040. $lock['packages'] = $this->lockPackages($packages);
  22041. if (null !== $devPackages) {
  22042. $lock['packages-dev'] = $this->lockPackages($devPackages);
  22043. }
  22044. $lock['platform'] = $platformReqs;
  22045. $lock['platform-dev'] = $platformDevReqs;
  22046. if ($platformOverrides) {
  22047. $lock['platform-overrides'] = $platformOverrides;
  22048. }
  22049. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  22050. try {
  22051. $isLocked = $this->isLocked();
  22052. } catch (ParsingException $e) {
  22053. $isLocked = false;
  22054. }
  22055. if (!$isLocked || $lock !== $this->getLockData()) {
  22056. if ($write) {
  22057. $this->lockFile->write($lock);
  22058. $this->lockDataCache = null;
  22059. $this->virtualFileWritten = false;
  22060. } else {
  22061. $this->virtualFileWritten = true;
  22062. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock, 448 & JsonFile::JSON_PRETTY_PRINT));
  22063. }
  22064. return true;
  22065. }
  22066. return false;
  22067. }
  22068. private function lockPackages(array $packages)
  22069. {
  22070. $locked = array();
  22071. foreach ($packages as $package) {
  22072. if ($package instanceof AliasPackage) {
  22073. continue;
  22074. }
  22075. $name = $package->getPrettyName();
  22076. $version = $package->getPrettyVersion();
  22077. if (!$name || !$version) {
  22078. throw new \LogicException(sprintf(
  22079. 'Package "%s" has no version or name and can not be locked',
  22080. $package
  22081. ));
  22082. }
  22083. $spec = $this->dumper->dump($package);
  22084. unset($spec['version_normalized']);
  22085. $time = isset($spec['time']) ? $spec['time'] : null;
  22086. unset($spec['time']);
  22087. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  22088. $time = $this->getPackageTime($package) ?: $time;
  22089. }
  22090. if (null !== $time) {
  22091. $spec['time'] = $time;
  22092. }
  22093. unset($spec['installation-source']);
  22094. $locked[] = $spec;
  22095. }
  22096. usort($locked, function ($a, $b) {
  22097. $comparison = strcmp($a['name'], $b['name']);
  22098. if (0 !== $comparison) {
  22099. return $comparison;
  22100. }
  22101. return strcmp($a['version'], $b['version']);
  22102. });
  22103. return $locked;
  22104. }
  22105. private function getPackageTime(PackageInterface $package)
  22106. {
  22107. if (!function_exists('proc_open')) {
  22108. return null;
  22109. }
  22110. $path = realpath($this->installationManager->getInstallPath($package));
  22111. $sourceType = $package->getSourceType();
  22112. $datetime = null;
  22113. if ($path && in_array($sourceType, array('git', 'hg'))) {
  22114. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  22115. switch ($sourceType) {
  22116. case 'git':
  22117. GitUtil::cleanEnv();
  22118. 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)) {
  22119. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  22120. }
  22121. break;
  22122. case 'hg':
  22123. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && preg_match('{^\s*(\d+)\s*}', $output, $match)) {
  22124. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  22125. }
  22126. break;
  22127. }
  22128. }
  22129. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  22130. }
  22131. }
  22132. <?php
  22133. namespace Composer\Package;
  22134. use Composer\Package\Version\VersionParser;
  22135. use Composer\Util\ComposerMirror;
  22136. class Package extends BasePackage
  22137. {
  22138. protected $type;
  22139. protected $targetDir;
  22140. protected $installationSource;
  22141. protected $sourceType;
  22142. protected $sourceUrl;
  22143. protected $sourceReference;
  22144. protected $sourceMirrors;
  22145. protected $distType;
  22146. protected $distUrl;
  22147. protected $distReference;
  22148. protected $distSha1Checksum;
  22149. protected $distMirrors;
  22150. protected $version;
  22151. protected $prettyVersion;
  22152. protected $releaseDate;
  22153. protected $extra = array();
  22154. protected $binaries = array();
  22155. protected $dev;
  22156. protected $stability;
  22157. protected $notificationUrl;
  22158. protected $requires = array();
  22159. protected $conflicts = array();
  22160. protected $provides = array();
  22161. protected $replaces = array();
  22162. protected $devRequires = array();
  22163. protected $suggests = array();
  22164. protected $autoload = array();
  22165. protected $devAutoload = array();
  22166. protected $includePaths = array();
  22167. protected $isDefaultBranch = false;
  22168. protected $transportOptions = array();
  22169. public function __construct($name, $version, $prettyVersion)
  22170. {
  22171. parent::__construct($name);
  22172. $this->version = $version;
  22173. $this->prettyVersion = $prettyVersion;
  22174. $this->stability = VersionParser::parseStability($version);
  22175. $this->dev = $this->stability === 'dev';
  22176. }
  22177. public function isDev()
  22178. {
  22179. return $this->dev;
  22180. }
  22181. public function setType($type)
  22182. {
  22183. $this->type = $type;
  22184. }
  22185. public function getType()
  22186. {
  22187. return $this->type ?: 'library';
  22188. }
  22189. public function getStability()
  22190. {
  22191. return $this->stability;
  22192. }
  22193. public function setTargetDir($targetDir)
  22194. {
  22195. $this->targetDir = $targetDir;
  22196. }
  22197. public function getTargetDir()
  22198. {
  22199. if (null === $this->targetDir) {
  22200. return null;
  22201. }
  22202. return ltrim(preg_replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  22203. }
  22204. public function setExtra(array $extra)
  22205. {
  22206. $this->extra = $extra;
  22207. }
  22208. public function getExtra()
  22209. {
  22210. return $this->extra;
  22211. }
  22212. public function setBinaries(array $binaries)
  22213. {
  22214. $this->binaries = $binaries;
  22215. }
  22216. public function getBinaries()
  22217. {
  22218. return $this->binaries;
  22219. }
  22220. public function setInstallationSource($type)
  22221. {
  22222. $this->installationSource = $type;
  22223. }
  22224. public function getInstallationSource()
  22225. {
  22226. return $this->installationSource;
  22227. }
  22228. public function setSourceType($type)
  22229. {
  22230. $this->sourceType = $type;
  22231. }
  22232. public function getSourceType()
  22233. {
  22234. return $this->sourceType;
  22235. }
  22236. public function setSourceUrl($url)
  22237. {
  22238. $this->sourceUrl = $url;
  22239. }
  22240. public function getSourceUrl()
  22241. {
  22242. return $this->sourceUrl;
  22243. }
  22244. public function setSourceReference($reference)
  22245. {
  22246. $this->sourceReference = $reference;
  22247. }
  22248. public function getSourceReference()
  22249. {
  22250. return $this->sourceReference;
  22251. }
  22252. public function setSourceMirrors($mirrors)
  22253. {
  22254. $this->sourceMirrors = $mirrors;
  22255. }
  22256. public function getSourceMirrors()
  22257. {
  22258. return $this->sourceMirrors;
  22259. }
  22260. public function getSourceUrls()
  22261. {
  22262. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  22263. }
  22264. public function setDistType($type)
  22265. {
  22266. $this->distType = $type;
  22267. }
  22268. public function getDistType()
  22269. {
  22270. return $this->distType;
  22271. }
  22272. public function setDistUrl($url)
  22273. {
  22274. $this->distUrl = $url;
  22275. }
  22276. public function getDistUrl()
  22277. {
  22278. return $this->distUrl;
  22279. }
  22280. public function setDistReference($reference)
  22281. {
  22282. $this->distReference = $reference;
  22283. }
  22284. public function getDistReference()
  22285. {
  22286. return $this->distReference;
  22287. }
  22288. public function setDistSha1Checksum($sha1checksum)
  22289. {
  22290. $this->distSha1Checksum = $sha1checksum;
  22291. }
  22292. public function getDistSha1Checksum()
  22293. {
  22294. return $this->distSha1Checksum;
  22295. }
  22296. public function setDistMirrors($mirrors)
  22297. {
  22298. $this->distMirrors = $mirrors;
  22299. }
  22300. public function getDistMirrors()
  22301. {
  22302. return $this->distMirrors;
  22303. }
  22304. public function getDistUrls()
  22305. {
  22306. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  22307. }
  22308. public function getTransportOptions()
  22309. {
  22310. return $this->transportOptions;
  22311. }
  22312. public function setTransportOptions(array $options)
  22313. {
  22314. $this->transportOptions = $options;
  22315. }
  22316. public function getVersion()
  22317. {
  22318. return $this->version;
  22319. }
  22320. public function getPrettyVersion()
  22321. {
  22322. return $this->prettyVersion;
  22323. }
  22324. public function setReleaseDate(\DateTime $releaseDate)
  22325. {
  22326. $this->releaseDate = $releaseDate;
  22327. }
  22328. public function getReleaseDate()
  22329. {
  22330. return $this->releaseDate;
  22331. }
  22332. public function setRequires(array $requires)
  22333. {
  22334. $this->requires = $requires;
  22335. }
  22336. public function getRequires()
  22337. {
  22338. return $this->requires;
  22339. }
  22340. public function setConflicts(array $conflicts)
  22341. {
  22342. $this->conflicts = $conflicts;
  22343. }
  22344. public function getConflicts()
  22345. {
  22346. return $this->conflicts;
  22347. }
  22348. public function setProvides(array $provides)
  22349. {
  22350. $this->provides = $provides;
  22351. }
  22352. public function getProvides()
  22353. {
  22354. return $this->provides;
  22355. }
  22356. public function setReplaces(array $replaces)
  22357. {
  22358. $this->replaces = $replaces;
  22359. }
  22360. public function getReplaces()
  22361. {
  22362. return $this->replaces;
  22363. }
  22364. public function setDevRequires(array $devRequires)
  22365. {
  22366. $this->devRequires = $devRequires;
  22367. }
  22368. public function getDevRequires()
  22369. {
  22370. return $this->devRequires;
  22371. }
  22372. public function setSuggests(array $suggests)
  22373. {
  22374. $this->suggests = $suggests;
  22375. }
  22376. public function getSuggests()
  22377. {
  22378. return $this->suggests;
  22379. }
  22380. public function setAutoload(array $autoload)
  22381. {
  22382. $this->autoload = $autoload;
  22383. }
  22384. public function getAutoload()
  22385. {
  22386. return $this->autoload;
  22387. }
  22388. public function setDevAutoload(array $devAutoload)
  22389. {
  22390. $this->devAutoload = $devAutoload;
  22391. }
  22392. public function getDevAutoload()
  22393. {
  22394. return $this->devAutoload;
  22395. }
  22396. public function setIncludePaths(array $includePaths)
  22397. {
  22398. $this->includePaths = $includePaths;
  22399. }
  22400. public function getIncludePaths()
  22401. {
  22402. return $this->includePaths;
  22403. }
  22404. public function setNotificationUrl($notificationUrl)
  22405. {
  22406. $this->notificationUrl = $notificationUrl;
  22407. }
  22408. public function getNotificationUrl()
  22409. {
  22410. return $this->notificationUrl;
  22411. }
  22412. public function setIsDefaultBranch($defaultBranch)
  22413. {
  22414. $this->isDefaultBranch = $defaultBranch;
  22415. }
  22416. public function isDefaultBranch()
  22417. {
  22418. return $this->isDefaultBranch;
  22419. }
  22420. public function setSourceDistReferences($reference)
  22421. {
  22422. $this->setSourceReference($reference);
  22423. if (
  22424. $this->getDistUrl() !== null
  22425. && preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())
  22426. ) {
  22427. $this->setDistReference($reference);
  22428. $this->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  22429. } elseif ($this->getDistReference()) {
  22430. $this->setDistReference($reference);
  22431. }
  22432. }
  22433. public function replaceVersion($version, $prettyVersion)
  22434. {
  22435. $this->version = $version;
  22436. $this->prettyVersion = $prettyVersion;
  22437. $this->stability = VersionParser::parseStability($version);
  22438. $this->dev = $this->stability === 'dev';
  22439. }
  22440. protected function getUrls($url, $mirrors, $ref, $type, $urlType)
  22441. {
  22442. if (!$url) {
  22443. return array();
  22444. }
  22445. if ($urlType === 'dist' && false !== strpos($url, '%')) {
  22446. $url = ComposerMirror::processUrl($url, $this->name, $this->version, $ref, $type, $this->prettyVersion);
  22447. }
  22448. $urls = array($url);
  22449. if ($mirrors) {
  22450. foreach ($mirrors as $mirror) {
  22451. if ($urlType === 'dist') {
  22452. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type, $this->prettyVersion);
  22453. } elseif ($urlType === 'source' && $type === 'git') {
  22454. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  22455. } elseif ($urlType === 'source' && $type === 'hg') {
  22456. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  22457. } else {
  22458. continue;
  22459. }
  22460. if (!\in_array($mirrorUrl, $urls)) {
  22461. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  22462. $func($urls, $mirrorUrl);
  22463. }
  22464. }
  22465. }
  22466. return $urls;
  22467. }
  22468. }
  22469. <?php
  22470. namespace Composer\Package;
  22471. use Composer\Repository\RepositoryInterface;
  22472. interface PackageInterface
  22473. {
  22474. const DISPLAY_SOURCE_REF_IF_DEV = 0;
  22475. const DISPLAY_SOURCE_REF = 1;
  22476. const DISPLAY_DIST_REF = 2;
  22477. public function getName();
  22478. public function getPrettyName();
  22479. public function getNames($provides = true);
  22480. public function setId($id);
  22481. public function getId();
  22482. public function isDev();
  22483. public function getType();
  22484. public function getTargetDir();
  22485. public function getExtra();
  22486. public function setInstallationSource($type);
  22487. public function getInstallationSource();
  22488. public function getSourceType();
  22489. public function getSourceUrl();
  22490. public function getSourceUrls();
  22491. public function getSourceReference();
  22492. public function getSourceMirrors();
  22493. public function setSourceMirrors($mirrors);
  22494. public function getDistType();
  22495. public function getDistUrl();
  22496. public function getDistUrls();
  22497. public function getDistReference();
  22498. public function getDistSha1Checksum();
  22499. public function getDistMirrors();
  22500. public function setDistMirrors($mirrors);
  22501. public function getVersion();
  22502. public function getPrettyVersion();
  22503. public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
  22504. public function getReleaseDate();
  22505. public function getStability();
  22506. public function getRequires();
  22507. public function getConflicts();
  22508. public function getProvides();
  22509. public function getReplaces();
  22510. public function getDevRequires();
  22511. public function getSuggests();
  22512. public function getAutoload();
  22513. public function getDevAutoload();
  22514. public function getIncludePaths();
  22515. public function setRepository(RepositoryInterface $repository);
  22516. public function getRepository();
  22517. public function getBinaries();
  22518. public function getUniqueName();
  22519. public function getNotificationUrl();
  22520. public function __toString();
  22521. public function getPrettyString();
  22522. public function isDefaultBranch();
  22523. public function getTransportOptions();
  22524. public function setTransportOptions(array $options);
  22525. public function setSourceReference($reference);
  22526. public function setDistUrl($url);
  22527. public function setDistType($type);
  22528. public function setDistReference($reference);
  22529. public function setSourceDistReferences($reference);
  22530. }
  22531. <?php
  22532. namespace Composer\Package;
  22533. class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterface
  22534. {
  22535. protected $aliasOf;
  22536. public function __construct(RootPackage $aliasOf, $version, $prettyVersion)
  22537. {
  22538. parent::__construct($aliasOf, $version, $prettyVersion);
  22539. }
  22540. public function getAliasOf()
  22541. {
  22542. return $this->aliasOf;
  22543. }
  22544. public function getAliases()
  22545. {
  22546. return $this->aliasOf->getAliases();
  22547. }
  22548. public function getMinimumStability()
  22549. {
  22550. return $this->aliasOf->getMinimumStability();
  22551. }
  22552. public function getStabilityFlags()
  22553. {
  22554. return $this->aliasOf->getStabilityFlags();
  22555. }
  22556. public function getReferences()
  22557. {
  22558. return $this->aliasOf->getReferences();
  22559. }
  22560. public function getPreferStable()
  22561. {
  22562. return $this->aliasOf->getPreferStable();
  22563. }
  22564. public function getConfig()
  22565. {
  22566. return $this->aliasOf->getConfig();
  22567. }
  22568. public function setRequires(array $require)
  22569. {
  22570. $this->requires = $this->replaceSelfVersionDependencies($require, Link::TYPE_REQUIRE);
  22571. $this->aliasOf->setRequires($require);
  22572. }
  22573. public function setDevRequires(array $devRequire)
  22574. {
  22575. $this->devRequires = $this->replaceSelfVersionDependencies($devRequire, Link::TYPE_DEV_REQUIRE);
  22576. $this->aliasOf->setDevRequires($devRequire);
  22577. }
  22578. public function setConflicts(array $conflicts)
  22579. {
  22580. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  22581. $this->aliasOf->setConflicts($conflicts);
  22582. }
  22583. public function setProvides(array $provides)
  22584. {
  22585. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  22586. $this->aliasOf->setProvides($provides);
  22587. }
  22588. public function setReplaces(array $replaces)
  22589. {
  22590. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  22591. $this->aliasOf->setReplaces($replaces);
  22592. }
  22593. public function setAutoload(array $autoload)
  22594. {
  22595. $this->aliasOf->setAutoload($autoload);
  22596. }
  22597. public function setDevAutoload(array $devAutoload)
  22598. {
  22599. $this->aliasOf->setDevAutoload($devAutoload);
  22600. }
  22601. public function setStabilityFlags(array $stabilityFlags)
  22602. {
  22603. $this->aliasOf->setStabilityFlags($stabilityFlags);
  22604. }
  22605. public function setMinimumStability($minimumStability)
  22606. {
  22607. $this->aliasOf->setMinimumStability($minimumStability);
  22608. }
  22609. public function setPreferStable($preferStable)
  22610. {
  22611. $this->aliasOf->setPreferStable($preferStable);
  22612. }
  22613. public function setConfig(array $config)
  22614. {
  22615. $this->aliasOf->setConfig($config);
  22616. }
  22617. public function setReferences(array $references)
  22618. {
  22619. $this->aliasOf->setReferences($references);
  22620. }
  22621. public function setAliases(array $aliases)
  22622. {
  22623. $this->aliasOf->setAliases($aliases);
  22624. }
  22625. public function setSuggests(array $suggests)
  22626. {
  22627. $this->aliasOf->setSuggests($suggests);
  22628. }
  22629. public function setExtra(array $extra)
  22630. {
  22631. $this->aliasOf->setExtra($extra);
  22632. }
  22633. public function __clone()
  22634. {
  22635. parent::__clone();
  22636. $this->aliasOf = clone $this->aliasOf;
  22637. }
  22638. }
  22639. <?php
  22640. namespace Composer\Package;
  22641. class RootPackage extends CompletePackage implements RootPackageInterface
  22642. {
  22643. const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
  22644. protected $minimumStability = 'stable';
  22645. protected $preferStable = false;
  22646. protected $stabilityFlags = array();
  22647. protected $config = array();
  22648. protected $references = array();
  22649. protected $aliases = array();
  22650. public function setMinimumStability($minimumStability)
  22651. {
  22652. $this->minimumStability = $minimumStability;
  22653. }
  22654. public function getMinimumStability()
  22655. {
  22656. return $this->minimumStability;
  22657. }
  22658. public function setStabilityFlags(array $stabilityFlags)
  22659. {
  22660. $this->stabilityFlags = $stabilityFlags;
  22661. }
  22662. public function getStabilityFlags()
  22663. {
  22664. return $this->stabilityFlags;
  22665. }
  22666. public function setPreferStable($preferStable)
  22667. {
  22668. $this->preferStable = $preferStable;
  22669. }
  22670. public function getPreferStable()
  22671. {
  22672. return $this->preferStable;
  22673. }
  22674. public function setConfig(array $config)
  22675. {
  22676. $this->config = $config;
  22677. }
  22678. public function getConfig()
  22679. {
  22680. return $this->config;
  22681. }
  22682. public function setReferences(array $references)
  22683. {
  22684. $this->references = $references;
  22685. }
  22686. public function getReferences()
  22687. {
  22688. return $this->references;
  22689. }
  22690. public function setAliases(array $aliases)
  22691. {
  22692. $this->aliases = $aliases;
  22693. }
  22694. public function getAliases()
  22695. {
  22696. return $this->aliases;
  22697. }
  22698. }
  22699. <?php
  22700. namespace Composer\Package;
  22701. interface RootPackageInterface extends CompletePackageInterface
  22702. {
  22703. public function getAliases();
  22704. public function getMinimumStability();
  22705. public function getStabilityFlags();
  22706. public function getReferences();
  22707. public function getPreferStable();
  22708. public function getConfig();
  22709. public function setRequires(array $requires);
  22710. public function setDevRequires(array $devRequires);
  22711. public function setConflicts(array $conflicts);
  22712. public function setProvides(array $provides);
  22713. public function setReplaces(array $replaces);
  22714. public function setRepositories(array $repositories);
  22715. public function setAutoload(array $autoload);
  22716. public function setDevAutoload(array $devAutoload);
  22717. public function setStabilityFlags(array $stabilityFlags);
  22718. public function setMinimumStability($minimumStability);
  22719. public function setPreferStable($preferStable);
  22720. public function setConfig(array $config);
  22721. public function setReferences(array $references);
  22722. public function setAliases(array $aliases);
  22723. public function setSuggests(array $suggests);
  22724. public function setExtra(array $extra);
  22725. }
  22726. <?php
  22727. namespace Composer\Package\Version;
  22728. use Composer\Package\BasePackage;
  22729. class StabilityFilter
  22730. {
  22731. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, array $names, $stability)
  22732. {
  22733. foreach ($names as $name) {
  22734. if (isset($stabilityFlags[$name])) {
  22735. if (BasePackage::$stabilities[$stability] <= $stabilityFlags[$name]) {
  22736. return true;
  22737. }
  22738. } elseif (isset($acceptableStabilities[$stability])) {
  22739. return true;
  22740. }
  22741. }
  22742. return false;
  22743. }
  22744. }
  22745. <?php
  22746. namespace Composer\Package\Version;
  22747. use Composer\Config;
  22748. use Composer\Repository\Vcs\HgDriver;
  22749. use Composer\IO\NullIO;
  22750. use Composer\Semver\VersionParser as SemverVersionParser;
  22751. use Composer\Util\Git as GitUtil;
  22752. use Composer\Util\HttpDownloader;
  22753. use Composer\Util\ProcessExecutor;
  22754. use Composer\Util\Svn as SvnUtil;
  22755. class VersionGuesser
  22756. {
  22757. private $config;
  22758. private $process;
  22759. private $versionParser;
  22760. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  22761. {
  22762. $this->config = $config;
  22763. $this->process = $process;
  22764. $this->versionParser = $versionParser;
  22765. }
  22766. public function guessVersion(array $packageConfig, $path)
  22767. {
  22768. if (!function_exists('proc_open')) {
  22769. return null;
  22770. }
  22771. $versionData = $this->guessGitVersion($packageConfig, $path);
  22772. if (null !== $versionData && null !== $versionData['version']) {
  22773. return $this->postprocess($versionData);
  22774. }
  22775. $versionData = $this->guessHgVersion($packageConfig, $path);
  22776. if (null !== $versionData && null !== $versionData['version']) {
  22777. return $this->postprocess($versionData);
  22778. }
  22779. $versionData = $this->guessFossilVersion($path);
  22780. if (null !== $versionData && null !== $versionData['version']) {
  22781. return $this->postprocess($versionData);
  22782. }
  22783. $versionData = $this->guessSvnVersion($packageConfig, $path);
  22784. if (null !== $versionData && null !== $versionData['version']) {
  22785. return $this->postprocess($versionData);
  22786. }
  22787. return null;
  22788. }
  22789. private function postprocess(array $versionData)
  22790. {
  22791. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  22792. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  22793. }
  22794. if ('-dev' === substr($versionData['version'], -4) && preg_match('{\.9{7}}', $versionData['version'])) {
  22795. $versionData['pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['version']);
  22796. }
  22797. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && preg_match('{\.9{7}}', $versionData['feature_version'])) {
  22798. $versionData['feature_pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  22799. }
  22800. return $versionData;
  22801. }
  22802. private function guessGitVersion(array $packageConfig, $path)
  22803. {
  22804. GitUtil::cleanEnv();
  22805. $commit = null;
  22806. $version = null;
  22807. $prettyVersion = null;
  22808. $featureVersion = null;
  22809. $featurePrettyVersion = null;
  22810. $isDetached = false;
  22811. if (0 === $this->process->execute('git branch -a --no-color --no-abbrev -v', $output, $path)) {
  22812. $branches = array();
  22813. $isFeatureBranch = false;
  22814. foreach ($this->process->splitLines($output) as $branch) {
  22815. if ($branch && preg_match('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  22816. if (
  22817. $match[1] === '(no branch)'
  22818. || strpos($match[1], '(detached ') === 0
  22819. || strpos($match[1], '(HEAD detached at') === 0
  22820. ) {
  22821. $version = 'dev-' . $match[2];
  22822. $prettyVersion = $version;
  22823. $isFeatureBranch = true;
  22824. $isDetached = true;
  22825. } else {
  22826. $version = $this->versionParser->normalizeBranch($match[1]);
  22827. $prettyVersion = 'dev-' . $match[1];
  22828. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  22829. }
  22830. if ($match[2]) {
  22831. $commit = $match[2];
  22832. }
  22833. }
  22834. if ($branch && !preg_match('{^ *.+/HEAD }', $branch)) {
  22835. if (preg_match('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  22836. $branches[] = $match[1];
  22837. }
  22838. }
  22839. }
  22840. if ($isFeatureBranch) {
  22841. $featureVersion = $version;
  22842. $featurePrettyVersion = $prettyVersion;
  22843. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  22844. $version = $result['version'];
  22845. $prettyVersion = $result['pretty_version'];
  22846. }
  22847. }
  22848. if (!$version || $isDetached) {
  22849. $result = $this->versionFromGitTags($path);
  22850. if ($result) {
  22851. $version = $result['version'];
  22852. $prettyVersion = $result['pretty_version'];
  22853. $featureVersion = null;
  22854. $featurePrettyVersion = null;
  22855. }
  22856. }
  22857. if (!$commit) {
  22858. $command = 'git log --pretty="%H" -n1 HEAD'.GitUtil::getNoShowSignatureFlag($this->process);
  22859. if (0 === $this->process->execute($command, $output, $path)) {
  22860. $commit = trim($output) ?: null;
  22861. }
  22862. }
  22863. if ($featureVersion) {
  22864. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion);
  22865. }
  22866. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion);
  22867. }
  22868. private function versionFromGitTags($path)
  22869. {
  22870. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  22871. try {
  22872. $version = $this->versionParser->normalize(trim($output));
  22873. return array('version' => $version, 'pretty_version' => trim($output));
  22874. } catch (\Exception $e) {
  22875. }
  22876. }
  22877. return null;
  22878. }
  22879. private function guessHgVersion(array $packageConfig, $path)
  22880. {
  22881. if (0 === $this->process->execute('hg branch', $output, $path)) {
  22882. $branch = trim($output);
  22883. $version = $this->versionParser->normalizeBranch($branch);
  22884. $isFeatureBranch = 0 === strpos($version, 'dev-');
  22885. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  22886. return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
  22887. }
  22888. if (!$isFeatureBranch) {
  22889. return array('version' => $version, 'commit' => null, 'pretty_version' => $version);
  22890. }
  22891. $io = new NullIO();
  22892. $driver = new HgDriver(array('url' => $path), $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  22893. $branches = array_keys($driver->getBranches());
  22894. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  22895. $result['commit'] = '';
  22896. $result['feature_version'] = $version;
  22897. $result['feature_pretty_version'] = $version;
  22898. return $result;
  22899. }
  22900. return null;
  22901. }
  22902. private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path)
  22903. {
  22904. $prettyVersion = $version;
  22905. if (!isset($packageConfig['extra']['branch-alias'][$version])
  22906. || strpos(json_encode($packageConfig), '"self.version"')
  22907. ) {
  22908. $branch = preg_replace('{^dev-}', '', $version);
  22909. $length = PHP_INT_MAX;
  22910. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  22911. return array('version' => $version, 'pretty_version' => $prettyVersion);
  22912. }
  22913. usort($branches, function ($a, $b) {
  22914. $aRemote = 0 === strpos($a, 'remotes/');
  22915. $bRemote = 0 === strpos($b, 'remotes/');
  22916. if ($aRemote !== $bRemote) {
  22917. return $aRemote ? 1 : -1;
  22918. }
  22919. return strnatcasecmp($b, $a);
  22920. });
  22921. foreach ($branches as $candidate) {
  22922. $candidateVersion = preg_replace('{^remotes/\S+/}', '', $candidate);
  22923. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  22924. continue;
  22925. }
  22926. $cmdLine = str_replace(array('%candidate%', '%branch%'), array($candidate, $branch), $scmCmdline);
  22927. if (0 !== $this->process->execute($cmdLine, $output, $path)) {
  22928. continue;
  22929. }
  22930. if (strlen($output) < $length) {
  22931. $length = strlen($output);
  22932. $version = $this->versionParser->normalizeBranch($candidateVersion);
  22933. $prettyVersion = 'dev-' . $candidateVersion;
  22934. if ($length === 0) {
  22935. break;
  22936. }
  22937. }
  22938. }
  22939. }
  22940. return array('version' => $version, 'pretty_version' => $prettyVersion);
  22941. }
  22942. private function isFeatureBranch(array $packageConfig, $branchName)
  22943. {
  22944. $nonFeatureBranches = '';
  22945. if (!empty($packageConfig['non-feature-branches'])) {
  22946. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  22947. }
  22948. return !preg_match('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  22949. }
  22950. private function guessFossilVersion($path)
  22951. {
  22952. $version = null;
  22953. $prettyVersion = null;
  22954. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  22955. $branch = trim($output);
  22956. $version = $this->versionParser->normalizeBranch($branch);
  22957. $prettyVersion = 'dev-' . $branch;
  22958. }
  22959. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  22960. try {
  22961. $version = $this->versionParser->normalize(trim($output));
  22962. $prettyVersion = trim($output);
  22963. } catch (\Exception $e) {
  22964. }
  22965. }
  22966. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  22967. }
  22968. private function guessSvnVersion(array $packageConfig, $path)
  22969. {
  22970. SvnUtil::cleanEnv();
  22971. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  22972. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  22973. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  22974. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  22975. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  22976. if (preg_match($urlPattern, $output, $matches)) {
  22977. if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  22978. $version = $this->versionParser->normalizeBranch($matches[3]);
  22979. $prettyVersion = 'dev-' . $matches[3];
  22980. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  22981. }
  22982. $prettyVersion = trim($matches[1]);
  22983. if ($prettyVersion === 'trunk') {
  22984. $version = 'dev-trunk';
  22985. } else {
  22986. $version = $this->versionParser->normalize($prettyVersion);
  22987. }
  22988. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  22989. }
  22990. }
  22991. return null;
  22992. }
  22993. }
  22994. <?php
  22995. namespace Composer\Package\Version;
  22996. use Composer\Repository\PlatformRepository;
  22997. use Composer\Semver\VersionParser as SemverVersionParser;
  22998. use Composer\Semver\Semver;
  22999. use Composer\Semver\Constraint\ConstraintInterface;
  23000. class VersionParser extends SemverVersionParser
  23001. {
  23002. const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  23003. private static $constraints = array();
  23004. public function parseConstraints($constraints)
  23005. {
  23006. if (!isset(self::$constraints[$constraints])) {
  23007. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  23008. }
  23009. return self::$constraints[$constraints];
  23010. }
  23011. public function parseNameVersionPairs(array $pairs)
  23012. {
  23013. $pairs = array_values($pairs);
  23014. $result = array();
  23015. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  23016. $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  23017. if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !preg_match('{(?<=[a-z0-9_/-])\*|\*(?=[a-z0-9_/-])}i', $pairs[$i + 1]) && !PlatformRepository::isPlatformPackage($pairs[$i + 1])) {
  23018. $pair .= ' '.$pairs[$i + 1];
  23019. $i++;
  23020. }
  23021. if (strpos($pair, ' ')) {
  23022. list($name, $version) = explode(' ', $pair, 2);
  23023. $result[] = array('name' => $name, 'version' => $version);
  23024. } else {
  23025. $result[] = array('name' => $pair);
  23026. }
  23027. }
  23028. return $result;
  23029. }
  23030. public static function isUpgrade($normalizedFrom, $normalizedTo)
  23031. {
  23032. if ($normalizedFrom === $normalizedTo) {
  23033. return true;
  23034. }
  23035. if (in_array($normalizedFrom, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  23036. $normalizedFrom = VersionParser::DEFAULT_BRANCH_ALIAS;
  23037. }
  23038. if (in_array($normalizedTo, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  23039. $normalizedTo = VersionParser::DEFAULT_BRANCH_ALIAS;
  23040. }
  23041. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  23042. return true;
  23043. }
  23044. $sorted = Semver::sort(array($normalizedTo, $normalizedFrom));
  23045. return $sorted[0] === $normalizedFrom;
  23046. }
  23047. }
  23048. <?php
  23049. namespace Composer\Package\Version;
  23050. use Composer\Package\BasePackage;
  23051. use Composer\Package\AliasPackage;
  23052. use Composer\Package\PackageInterface;
  23053. use Composer\Composer;
  23054. use Composer\Package\Loader\ArrayLoader;
  23055. use Composer\Package\Dumper\ArrayDumper;
  23056. use Composer\Repository\RepositorySet;
  23057. use Composer\Repository\PlatformRepository;
  23058. use Composer\Semver\Constraint\Constraint;
  23059. use Composer\Semver\Constraint\ConstraintInterface;
  23060. class VersionSelector
  23061. {
  23062. private $repositorySet;
  23063. private $platformConstraints = array();
  23064. private $parser;
  23065. public function __construct(RepositorySet $repositorySet, PlatformRepository $platformRepo = null)
  23066. {
  23067. $this->repositorySet = $repositorySet;
  23068. if ($platformRepo) {
  23069. foreach ($platformRepo->getPackages() as $package) {
  23070. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  23071. }
  23072. }
  23073. }
  23074. public function findBestCandidate($packageName, $targetPackageVersion = null, $preferredStability = 'stable', $ignorePlatformReqs = false, $repoSetFlags = 0)
  23075. {
  23076. if (!isset(BasePackage::$stabilities[$preferredStability])) {
  23077. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  23078. }
  23079. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  23080. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint, $repoSetFlags);
  23081. if ($this->platformConstraints && true !== $ignorePlatformReqs) {
  23082. $platformConstraints = $this->platformConstraints;
  23083. $ignorePlatformReqs = $ignorePlatformReqs ?: array();
  23084. $candidates = array_filter($candidates, function ($pkg) use ($platformConstraints, $ignorePlatformReqs) {
  23085. $reqs = $pkg->getRequires();
  23086. foreach ($reqs as $name => $link) {
  23087. if (!in_array($name, $ignorePlatformReqs, true)) {
  23088. if (isset($platformConstraints[$name])) {
  23089. foreach ($platformConstraints[$name] as $constraint) {
  23090. if ($link->getConstraint()->matches($constraint)) {
  23091. continue 2;
  23092. }
  23093. }
  23094. return false;
  23095. } elseif (PlatformRepository::isPlatformPackage($name)) {
  23096. return false;
  23097. }
  23098. }
  23099. }
  23100. return true;
  23101. });
  23102. }
  23103. if (!$candidates) {
  23104. return false;
  23105. }
  23106. $package = reset($candidates);
  23107. $minPriority = BasePackage::$stabilities[$preferredStability];
  23108. foreach ($candidates as $candidate) {
  23109. $candidatePriority = $candidate->getStabilityPriority();
  23110. $currentPriority = $package->getStabilityPriority();
  23111. if ($minPriority < $candidatePriority && $currentPriority < $candidatePriority) {
  23112. continue;
  23113. }
  23114. if ($minPriority < $candidatePriority && $candidatePriority < $currentPriority) {
  23115. $package = $candidate;
  23116. continue;
  23117. }
  23118. if ($minPriority >= $candidatePriority && $minPriority < $currentPriority) {
  23119. $package = $candidate;
  23120. continue;
  23121. }
  23122. if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
  23123. $package = $candidate;
  23124. }
  23125. }
  23126. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23127. $package = $package->getAliasOf();
  23128. }
  23129. return $package;
  23130. }
  23131. public function findRecommendedRequireVersion(PackageInterface $package)
  23132. {
  23133. if (0 === strpos($package->getName(), 'ext-')) {
  23134. $phpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  23135. $extVersion = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  23136. if ($phpVersion === $extVersion) {
  23137. return '*';
  23138. }
  23139. }
  23140. $version = $package->getVersion();
  23141. if (!$package->isDev()) {
  23142. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  23143. }
  23144. $loader = new ArrayLoader($this->getParser());
  23145. $dumper = new ArrayDumper();
  23146. $extra = $loader->getBranchAlias($dumper->dump($package));
  23147. if ($extra && $extra !== VersionParser::DEFAULT_BRANCH_ALIAS) {
  23148. $extra = preg_replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  23149. if ($count) {
  23150. $extra = str_replace('.9999999', '.0', $extra);
  23151. return $this->transformVersion($extra, $extra, 'dev');
  23152. }
  23153. }
  23154. return $package->getPrettyVersion();
  23155. }
  23156. private function transformVersion($version, $prettyVersion, $stability)
  23157. {
  23158. $semanticVersionParts = explode('.', $version);
  23159. if (count($semanticVersionParts) == 4 && preg_match('{^0\D?}', $semanticVersionParts[3])) {
  23160. if ($semanticVersionParts[0] === '0') {
  23161. unset($semanticVersionParts[3]);
  23162. } else {
  23163. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  23164. }
  23165. $version = implode('.', $semanticVersionParts);
  23166. } else {
  23167. return $prettyVersion;
  23168. }
  23169. if ($stability != 'stable') {
  23170. $version .= '@'.$stability;
  23171. }
  23172. return '^' . $version;
  23173. }
  23174. private function getParser()
  23175. {
  23176. if ($this->parser === null) {
  23177. $this->parser = new VersionParser();
  23178. }
  23179. return $this->parser;
  23180. }
  23181. }
  23182. <?php
  23183. namespace Composer\Platform;
  23184. use Composer\Util\Platform;
  23185. use Composer\Util\ProcessExecutor;
  23186. use Symfony\Component\Process\ExecutableFinder;
  23187. class HhvmDetector
  23188. {
  23189. private static $hhvmVersion = null;
  23190. private $executableFinder;
  23191. private $processExecutor;
  23192. public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
  23193. {
  23194. $this->executableFinder = $executableFinder;
  23195. $this->processExecutor = $processExecutor;
  23196. }
  23197. public function reset()
  23198. {
  23199. self::$hhvmVersion = null;
  23200. }
  23201. public function getVersion()
  23202. {
  23203. if (null !== self::$hhvmVersion) {
  23204. return self::$hhvmVersion ?: null;
  23205. }
  23206. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  23207. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  23208. self::$hhvmVersion = false;
  23209. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  23210. $hhvmPath = $this->executableFinder->find('hhvm');
  23211. if ($hhvmPath !== null) {
  23212. $this->processExecutor = $this->processExecutor ?: new ProcessExecutor();
  23213. $exitCode = $this->processExecutor->execute(
  23214. ProcessExecutor::escape($hhvmPath).
  23215. ' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
  23216. self::$hhvmVersion
  23217. );
  23218. if ($exitCode !== 0) {
  23219. self::$hhvmVersion = false;
  23220. }
  23221. }
  23222. }
  23223. return self::$hhvmVersion ?: null;
  23224. }
  23225. }
  23226. <?php
  23227. namespace Composer\Platform;
  23228. class Runtime
  23229. {
  23230. public function hasConstant($constant, $class = null)
  23231. {
  23232. return defined(ltrim($class.'::'.$constant, ':'));
  23233. }
  23234. public function getConstant($constant, $class = null)
  23235. {
  23236. return constant(ltrim($class.'::'.$constant, ':'));
  23237. }
  23238. public function hasFunction($fn)
  23239. {
  23240. return function_exists($fn);
  23241. }
  23242. public function invoke($callable, array $arguments = array())
  23243. {
  23244. return call_user_func_array($callable, $arguments);
  23245. }
  23246. public function hasClass($class)
  23247. {
  23248. return class_exists($class, false);
  23249. }
  23250. public function construct($class, array $arguments = array())
  23251. {
  23252. if (empty($arguments)) {
  23253. return new $class;
  23254. }
  23255. $refl = new \ReflectionClass($class);
  23256. return $refl->newInstanceArgs($arguments);
  23257. }
  23258. public function getExtensions()
  23259. {
  23260. return get_loaded_extensions();
  23261. }
  23262. public function getExtensionVersion($extension)
  23263. {
  23264. return phpversion($extension);
  23265. }
  23266. public function getExtensionInfo($extension)
  23267. {
  23268. $reflector = new \ReflectionExtension($extension);
  23269. ob_start();
  23270. $reflector->info();
  23271. return ob_get_clean();
  23272. }
  23273. }
  23274. <?php
  23275. namespace Composer\Platform;
  23276. class Version
  23277. {
  23278. public static function parseOpenssl($opensslVersion, &$isFips)
  23279. {
  23280. $isFips = false;
  23281. if (!preg_match('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})?(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)?(?<garbage>-\w+)?$/', $opensslVersion, $matches)) {
  23282. return null;
  23283. }
  23284. $isFips = strpos($matches['suffix'], 'fips') !== false;
  23285. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), array('-fips' => '', '-pre' => '-alpha'));
  23286. $patch = self::convertAlphaVersionToIntVersion($matches['patch']);
  23287. return rtrim($matches['version'].'.'.$patch.$suffix, '-');
  23288. }
  23289. public static function parseLibjpeg($libjpegVersion)
  23290. {
  23291. if (!preg_match('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  23292. return null;
  23293. }
  23294. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  23295. }
  23296. public static function parseZoneinfoVersion($zoneinfoVersion)
  23297. {
  23298. if (!preg_match('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  23299. return null;
  23300. }
  23301. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  23302. }
  23303. private static function convertAlphaVersionToIntVersion($alpha)
  23304. {
  23305. return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
  23306. }
  23307. public static function convertLibxpmVersionId($versionId)
  23308. {
  23309. return self::convertVersionId($versionId, 100);
  23310. }
  23311. public static function convertOpenldapVersionId($versionId)
  23312. {
  23313. return self::convertVersionId($versionId, 100);
  23314. }
  23315. private static function convertVersionId($versionId, $base)
  23316. {
  23317. return sprintf(
  23318. '%d.%d.%d',
  23319. $versionId / ($base * $base),
  23320. (int) ($versionId / $base) % $base,
  23321. $versionId % $base
  23322. );
  23323. }
  23324. }
  23325. <?php
  23326. namespace Composer\Plugin\Capability;
  23327. interface Capability
  23328. {
  23329. }
  23330. <?php
  23331. namespace Composer\Plugin\Capability;
  23332. interface CommandProvider extends Capability
  23333. {
  23334. public function getCommands();
  23335. }
  23336. <?php
  23337. namespace Composer\Plugin;
  23338. interface Capable
  23339. {
  23340. public function getCapabilities();
  23341. }
  23342. <?php
  23343. namespace Composer\Plugin;
  23344. use Composer\EventDispatcher\Event;
  23345. use Symfony\Component\Console\Input\InputInterface;
  23346. use Symfony\Component\Console\Output\OutputInterface;
  23347. class CommandEvent extends Event
  23348. {
  23349. private $commandName;
  23350. private $input;
  23351. private $output;
  23352. public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
  23353. {
  23354. parent::__construct($name, $args, $flags);
  23355. $this->commandName = $commandName;
  23356. $this->input = $input;
  23357. $this->output = $output;
  23358. }
  23359. public function getInput()
  23360. {
  23361. return $this->input;
  23362. }
  23363. public function getOutput()
  23364. {
  23365. return $this->output;
  23366. }
  23367. public function getCommandName()
  23368. {
  23369. return $this->commandName;
  23370. }
  23371. }
  23372. <?php
  23373. namespace Composer\Plugin;
  23374. class PluginEvents
  23375. {
  23376. const INIT = 'init';
  23377. const COMMAND = 'command';
  23378. const PRE_FILE_DOWNLOAD = 'pre-file-download';
  23379. const POST_FILE_DOWNLOAD = 'post-file-download';
  23380. const PRE_COMMAND_RUN = 'pre-command-run';
  23381. const PRE_POOL_CREATE = 'pre-pool-create';
  23382. }
  23383. <?php
  23384. namespace Composer\Plugin;
  23385. use Composer\Composer;
  23386. use Composer\IO\IOInterface;
  23387. interface PluginInterface
  23388. {
  23389. const PLUGIN_API_VERSION = '2.1.0';
  23390. public function activate(Composer $composer, IOInterface $io);
  23391. public function deactivate(Composer $composer, IOInterface $io);
  23392. public function uninstall(Composer $composer, IOInterface $io);
  23393. }
  23394. <?php
  23395. namespace Composer\Plugin;
  23396. use Composer\Composer;
  23397. use Composer\EventDispatcher\EventSubscriberInterface;
  23398. use Composer\IO\IOInterface;
  23399. use Composer\Package\CompletePackage;
  23400. use Composer\Package\Package;
  23401. use Composer\Package\Version\VersionParser;
  23402. use Composer\Repository\RepositoryInterface;
  23403. use Composer\Repository\InstalledRepository;
  23404. use Composer\Repository\RootPackageRepository;
  23405. use Composer\Package\PackageInterface;
  23406. use Composer\Package\Link;
  23407. use Composer\Semver\Constraint\Constraint;
  23408. use Composer\Plugin\Capability\Capability;
  23409. use Composer\Util\PackageSorter;
  23410. class PluginManager
  23411. {
  23412. protected $composer;
  23413. protected $io;
  23414. protected $globalComposer;
  23415. protected $versionParser;
  23416. protected $disablePlugins = false;
  23417. protected $plugins = array();
  23418. protected $registeredPlugins = array();
  23419. private static $classCounter = 0;
  23420. public function __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  23421. {
  23422. $this->io = $io;
  23423. $this->composer = $composer;
  23424. $this->globalComposer = $globalComposer;
  23425. $this->versionParser = new VersionParser();
  23426. $this->disablePlugins = $disablePlugins;
  23427. }
  23428. public function loadInstalledPlugins()
  23429. {
  23430. if ($this->disablePlugins) {
  23431. return;
  23432. }
  23433. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  23434. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  23435. $this->loadRepository($repo, false);
  23436. if ($globalRepo) {
  23437. $this->loadRepository($globalRepo, true);
  23438. }
  23439. }
  23440. public function getPlugins()
  23441. {
  23442. return $this->plugins;
  23443. }
  23444. public function getGlobalComposer()
  23445. {
  23446. return $this->globalComposer;
  23447. }
  23448. public function registerPackage(PackageInterface $package, $failOnMissingClasses = false, $isGlobalPlugin = false)
  23449. {
  23450. if ($this->disablePlugins) {
  23451. return;
  23452. }
  23453. if ($package->getType() === 'composer-plugin') {
  23454. $requiresComposer = null;
  23455. foreach ($package->getRequires() as $link) {
  23456. if ('composer-plugin-api' === $link->getTarget()) {
  23457. $requiresComposer = $link->getConstraint();
  23458. break;
  23459. }
  23460. }
  23461. if (!$requiresComposer) {
  23462. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  23463. }
  23464. $currentPluginApiVersion = $this->getPluginApiVersion();
  23465. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  23466. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  23467. $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>');
  23468. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  23469. $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>');
  23470. return;
  23471. }
  23472. if ($package->getName() === 'symfony/flex' && preg_match('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  23473. $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>');
  23474. return;
  23475. }
  23476. }
  23477. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  23478. if (isset($this->registeredPlugins[$package->getName()])) {
  23479. return;
  23480. }
  23481. $extra = $package->getExtra();
  23482. if (empty($extra['class'])) {
  23483. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  23484. }
  23485. $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']);
  23486. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  23487. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  23488. $rootPackage = clone $this->composer->getPackage();
  23489. $rootPackageRepo = new RootPackageRepository($rootPackage);
  23490. $installedRepo = new InstalledRepository(array($localRepo, $rootPackageRepo));
  23491. if ($globalRepo) {
  23492. $installedRepo->addRepository($globalRepo);
  23493. }
  23494. $autoloadPackages = array($package->getName() => $package);
  23495. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  23496. $generator = $this->composer->getAutoloadGenerator();
  23497. $autoloads = array(array($rootPackage, ''));
  23498. foreach ($autoloadPackages as $autoloadPackage) {
  23499. if ($autoloadPackage === $rootPackage) {
  23500. continue;
  23501. }
  23502. $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  23503. $autoloads[] = array($autoloadPackage, $downloadPath);
  23504. }
  23505. $map = $generator->parseAutoloads($autoloads, $rootPackage);
  23506. $classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  23507. $classLoader->register(false);
  23508. foreach ($classes as $class) {
  23509. if (class_exists($class, false)) {
  23510. $class = trim($class, '\\');
  23511. $path = $classLoader->findFile($class);
  23512. $code = file_get_contents($path);
  23513. $separatorPos = strrpos($class, '\\');
  23514. $className = $class;
  23515. if ($separatorPos) {
  23516. $className = substr($class, $separatorPos + 1);
  23517. }
  23518. $code = preg_replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  23519. $code = strtr($code, array(
  23520. '__FILE__' => var_export($path, true),
  23521. '__DIR__' => var_export(dirname($path), true),
  23522. '__CLASS__' => var_export($class, true),
  23523. ));
  23524. $code = preg_replace('/^\s*<\?(php)?/i', '', $code, 1);
  23525. eval($code);
  23526. $class .= '_composer_tmp'.self::$classCounter;
  23527. self::$classCounter++;
  23528. }
  23529. if ($oldInstallerPlugin) {
  23530. $this->io->writeError('<warning>Loading "'.$package->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').'which is a legacy composer-installer built for Composer 1.x, it is likely to cause issues as you are running Composer 2.x.</warning>');
  23531. $installer = new $class($this->io, $this->composer);
  23532. $this->composer->getInstallationManager()->addInstaller($installer);
  23533. $this->registeredPlugins[$package->getName()] = $installer;
  23534. } elseif (class_exists($class)) {
  23535. $plugin = new $class();
  23536. $this->addPlugin($plugin, $isGlobalPlugin, $package);
  23537. $this->registeredPlugins[$package->getName()] = $plugin;
  23538. } elseif ($failOnMissingClasses) {
  23539. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  23540. }
  23541. }
  23542. }
  23543. public function deactivatePackage(PackageInterface $package)
  23544. {
  23545. if ($this->disablePlugins) {
  23546. return;
  23547. }
  23548. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  23549. if (!isset($this->registeredPlugins[$package->getName()])) {
  23550. return;
  23551. }
  23552. if ($oldInstallerPlugin) {
  23553. $installer = $this->registeredPlugins[$package->getName()];
  23554. unset($this->registeredPlugins[$package->getName()]);
  23555. $this->composer->getInstallationManager()->removeInstaller($installer);
  23556. } else {
  23557. $plugin = $this->registeredPlugins[$package->getName()];
  23558. unset($this->registeredPlugins[$package->getName()]);
  23559. $this->removePlugin($plugin);
  23560. }
  23561. }
  23562. public function uninstallPackage(PackageInterface $package)
  23563. {
  23564. if ($this->disablePlugins) {
  23565. return;
  23566. }
  23567. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  23568. if (!isset($this->registeredPlugins[$package->getName()])) {
  23569. return;
  23570. }
  23571. if ($oldInstallerPlugin) {
  23572. $this->deactivatePackage($package);
  23573. } else {
  23574. $plugin = $this->registeredPlugins[$package->getName()];
  23575. unset($this->registeredPlugins[$package->getName()]);
  23576. $this->removePlugin($plugin);
  23577. $this->uninstallPlugin($plugin);
  23578. }
  23579. }
  23580. protected function getPluginApiVersion()
  23581. {
  23582. return PluginInterface::PLUGIN_API_VERSION;
  23583. }
  23584. public function addPlugin(PluginInterface $plugin, $isGlobalPlugin = false, PackageInterface $sourcePackage = null)
  23585. {
  23586. $details = array();
  23587. if ($sourcePackage) {
  23588. $details[] = 'from '.$sourcePackage->getName();
  23589. }
  23590. if ($isGlobalPlugin) {
  23591. $details[] = 'installed globally';
  23592. }
  23593. $this->io->writeError('Loading plugin '.get_class($plugin).($details ? ' ('.implode(', ', $details).')' : ''), true, IOInterface::DEBUG);
  23594. $this->plugins[] = $plugin;
  23595. $plugin->activate($this->composer, $this->io);
  23596. if ($plugin instanceof EventSubscriberInterface) {
  23597. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  23598. }
  23599. }
  23600. public function removePlugin(PluginInterface $plugin)
  23601. {
  23602. $index = array_search($plugin, $this->plugins, true);
  23603. if ($index === false) {
  23604. return;
  23605. }
  23606. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  23607. unset($this->plugins[$index]);
  23608. $plugin->deactivate($this->composer, $this->io);
  23609. $this->composer->getEventDispatcher()->removeListener($plugin);
  23610. }
  23611. public function uninstallPlugin(PluginInterface $plugin)
  23612. {
  23613. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  23614. $plugin->uninstall($this->composer, $this->io);
  23615. }
  23616. private function loadRepository(RepositoryInterface $repo, $isGlobalRepo)
  23617. {
  23618. $packages = $repo->getPackages();
  23619. $sortedPackages = PackageSorter::sortPackages($packages);
  23620. foreach ($sortedPackages as $package) {
  23621. if (!($package instanceof CompletePackage)) {
  23622. continue;
  23623. }
  23624. if ('composer-plugin' === $package->getType()) {
  23625. $this->registerPackage($package, false, $isGlobalRepo);
  23626. } elseif ('composer-installer' === $package->getType()) {
  23627. $this->registerPackage($package, false, $isGlobalRepo);
  23628. }
  23629. }
  23630. }
  23631. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package)
  23632. {
  23633. foreach ($package->getRequires() as $requireLink) {
  23634. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget()) as $requiredPackage) {
  23635. if (!isset($collected[$requiredPackage->getName()])) {
  23636. $collected[$requiredPackage->getName()] = $requiredPackage;
  23637. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  23638. }
  23639. }
  23640. }
  23641. return $collected;
  23642. }
  23643. private function getInstallPath(PackageInterface $package, $global = false)
  23644. {
  23645. if (!$global) {
  23646. return $this->composer->getInstallationManager()->getInstallPath($package);
  23647. }
  23648. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  23649. }
  23650. protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability)
  23651. {
  23652. if (!($plugin instanceof Capable)) {
  23653. return null;
  23654. }
  23655. $capabilities = (array) $plugin->getCapabilities();
  23656. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  23657. return trim($capabilities[$capability]);
  23658. }
  23659. if (
  23660. array_key_exists($capability, $capabilities)
  23661. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  23662. ) {
  23663. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], true));
  23664. }
  23665. return null;
  23666. }
  23667. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
  23668. {
  23669. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  23670. if (!class_exists($capabilityClass)) {
  23671. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  23672. }
  23673. $ctorArgs['plugin'] = $plugin;
  23674. $capabilityObj = new $capabilityClass($ctorArgs);
  23675. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  23676. throw new \RuntimeException(
  23677. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  23678. );
  23679. }
  23680. return $capabilityObj;
  23681. }
  23682. return null;
  23683. }
  23684. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())
  23685. {
  23686. $capabilities = array();
  23687. foreach ($this->getPlugins() as $plugin) {
  23688. if ($capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs)) {
  23689. $capabilities[] = $capability;
  23690. }
  23691. }
  23692. return $capabilities;
  23693. }
  23694. }
  23695. <?php
  23696. namespace Composer\Plugin;
  23697. use Composer\EventDispatcher\Event;
  23698. use Composer\Package\PackageInterface;
  23699. class PostFileDownloadEvent extends Event
  23700. {
  23701. private $fileName;
  23702. private $checksum;
  23703. private $url;
  23704. private $context;
  23705. private $type;
  23706. public function __construct($name, $fileName, $checksum, $url, $type, $context = null)
  23707. {
  23708. if ($context === null && $type instanceof PackageInterface) {
  23709. $context = $type;
  23710. $type = 'package';
  23711. trigger_error('PostFileDownloadEvent::__construct should receive a $type=package and the package object in $context since Composer 2.1.', E_USER_DEPRECATED);
  23712. }
  23713. parent::__construct($name);
  23714. $this->fileName = $fileName;
  23715. $this->checksum = $checksum;
  23716. $this->url = $url;
  23717. $this->context = $context;
  23718. $this->type = $type;
  23719. }
  23720. public function getFileName()
  23721. {
  23722. return $this->fileName;
  23723. }
  23724. public function getChecksum()
  23725. {
  23726. return $this->checksum;
  23727. }
  23728. public function getUrl()
  23729. {
  23730. return $this->url;
  23731. }
  23732. public function getContext()
  23733. {
  23734. return $this->context;
  23735. }
  23736. public function getPackage()
  23737. {
  23738. trigger_error('PostFileDownloadEvent::getPackage is deprecated since Composer 2.1, use getContext instead.', E_USER_DEPRECATED);
  23739. $context = $this->getContext();
  23740. return $context instanceof PackageInterface ? $context : null;
  23741. }
  23742. public function getType()
  23743. {
  23744. return $this->type;
  23745. }
  23746. }
  23747. <?php
  23748. namespace Composer\Plugin;
  23749. use Composer\EventDispatcher\Event;
  23750. use Symfony\Component\Console\Input\InputInterface;
  23751. class PreCommandRunEvent extends Event
  23752. {
  23753. private $input;
  23754. private $command;
  23755. public function __construct($name, InputInterface $input, $command)
  23756. {
  23757. parent::__construct($name);
  23758. $this->input = $input;
  23759. $this->command = $command;
  23760. }
  23761. public function getInput()
  23762. {
  23763. return $this->input;
  23764. }
  23765. public function getCommand()
  23766. {
  23767. return $this->command;
  23768. }
  23769. }
  23770. <?php
  23771. namespace Composer\Plugin;
  23772. use Composer\EventDispatcher\Event;
  23773. use Composer\Util\HttpDownloader;
  23774. class PreFileDownloadEvent extends Event
  23775. {
  23776. private $httpDownloader;
  23777. private $processedUrl;
  23778. private $customCacheKey;
  23779. private $type;
  23780. private $context;
  23781. private $transportOptions = array();
  23782. public function __construct($name, HttpDownloader $httpDownloader, $processedUrl, $type, $context = null)
  23783. {
  23784. parent::__construct($name);
  23785. $this->httpDownloader = $httpDownloader;
  23786. $this->processedUrl = $processedUrl;
  23787. $this->type = $type;
  23788. $this->context = $context;
  23789. }
  23790. public function getHttpDownloader()
  23791. {
  23792. return $this->httpDownloader;
  23793. }
  23794. public function getProcessedUrl()
  23795. {
  23796. return $this->processedUrl;
  23797. }
  23798. public function setProcessedUrl($processedUrl)
  23799. {
  23800. $this->processedUrl = $processedUrl;
  23801. }
  23802. public function getCustomCacheKey()
  23803. {
  23804. return $this->customCacheKey;
  23805. }
  23806. public function setCustomCacheKey($customCacheKey)
  23807. {
  23808. $this->customCacheKey = $customCacheKey;
  23809. }
  23810. public function getType()
  23811. {
  23812. return $this->type;
  23813. }
  23814. public function getContext()
  23815. {
  23816. return $this->context;
  23817. }
  23818. public function getTransportOptions()
  23819. {
  23820. return $this->transportOptions;
  23821. }
  23822. public function setTransportOptions(array $options)
  23823. {
  23824. $this->transportOptions = $options;
  23825. }
  23826. }
  23827. <?php
  23828. namespace Composer\Plugin;
  23829. use Composer\EventDispatcher\Event;
  23830. use Composer\Repository\RepositoryInterface;
  23831. use Composer\DependencyResolver\Request;
  23832. use Composer\Package\BasePackage;
  23833. class PrePoolCreateEvent extends Event
  23834. {
  23835. private $repositories;
  23836. private $request;
  23837. private $acceptableStabilities;
  23838. private $stabilityFlags;
  23839. private $rootAliases;
  23840. private $rootReferences;
  23841. private $packages;
  23842. private $unacceptableFixedPackages;
  23843. public function __construct($name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  23844. {
  23845. parent::__construct($name);
  23846. $this->repositories = $repositories;
  23847. $this->request = $request;
  23848. $this->acceptableStabilities = $acceptableStabilities;
  23849. $this->stabilityFlags = $stabilityFlags;
  23850. $this->rootAliases = $rootAliases;
  23851. $this->rootReferences = $rootReferences;
  23852. $this->packages = $packages;
  23853. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  23854. }
  23855. public function getRepositories()
  23856. {
  23857. return $this->repositories;
  23858. }
  23859. public function getRequest()
  23860. {
  23861. return $this->request;
  23862. }
  23863. public function getAcceptableStabilities()
  23864. {
  23865. return $this->acceptableStabilities;
  23866. }
  23867. public function getStabilityFlags()
  23868. {
  23869. return $this->stabilityFlags;
  23870. }
  23871. public function getRootAliases()
  23872. {
  23873. return $this->rootAliases;
  23874. }
  23875. public function getRootReferences()
  23876. {
  23877. return $this->rootReferences;
  23878. }
  23879. public function getPackages()
  23880. {
  23881. return $this->packages;
  23882. }
  23883. public function getUnacceptableFixedPackages()
  23884. {
  23885. return $this->unacceptableFixedPackages;
  23886. }
  23887. public function setPackages(array $packages)
  23888. {
  23889. $this->packages = $packages;
  23890. }
  23891. public function setUnacceptableFixedPackages(array $packages)
  23892. {
  23893. $this->unacceptableFixedPackages = $packages;
  23894. }
  23895. }
  23896. <?php
  23897. namespace Composer\Question;
  23898. use Symfony\Component\Console\Exception\InvalidArgumentException;
  23899. use Symfony\Component\Console\Question\Question;
  23900. class StrictConfirmationQuestion extends Question
  23901. {
  23902. private $trueAnswerRegex;
  23903. private $falseAnswerRegex;
  23904. public function __construct($question, $default = true, $trueAnswerRegex = '/^y(?:es)?$/i', $falseAnswerRegex = '/^no?$/i')
  23905. {
  23906. parent::__construct($question, (bool) $default);
  23907. $this->trueAnswerRegex = $trueAnswerRegex;
  23908. $this->falseAnswerRegex = $falseAnswerRegex;
  23909. $this->setNormalizer($this->getDefaultNormalizer());
  23910. $this->setValidator($this->getDefaultValidator());
  23911. }
  23912. private function getDefaultNormalizer()
  23913. {
  23914. $default = $this->getDefault();
  23915. $trueRegex = $this->trueAnswerRegex;
  23916. $falseRegex = $this->falseAnswerRegex;
  23917. return function ($answer) use ($default, $trueRegex, $falseRegex) {
  23918. if (is_bool($answer)) {
  23919. return $answer;
  23920. }
  23921. if (empty($answer) && !empty($default)) {
  23922. return $default;
  23923. }
  23924. if (preg_match($trueRegex, $answer)) {
  23925. return true;
  23926. }
  23927. if (preg_match($falseRegex, $answer)) {
  23928. return false;
  23929. }
  23930. return null;
  23931. };
  23932. }
  23933. private function getDefaultValidator()
  23934. {
  23935. return function ($answer) {
  23936. if (!is_bool($answer)) {
  23937. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  23938. }
  23939. return $answer;
  23940. };
  23941. }
  23942. }
  23943. <?php
  23944. namespace Composer\Repository;
  23945. use Composer\Package\AliasPackage;
  23946. use Composer\Package\BasePackage;
  23947. use Composer\Package\CompleteAliasPackage;
  23948. use Composer\Package\CompletePackage;
  23949. use Composer\Package\PackageInterface;
  23950. use Composer\Package\CompletePackageInterface;
  23951. use Composer\Package\Version\VersionParser;
  23952. use Composer\Package\Version\StabilityFilter;
  23953. use Composer\Semver\Constraint\ConstraintInterface;
  23954. use Composer\Semver\Constraint\Constraint;
  23955. class ArrayRepository implements RepositoryInterface
  23956. {
  23957. protected $packages = null;
  23958. protected $packageMap = null;
  23959. public function __construct(array $packages = array())
  23960. {
  23961. foreach ($packages as $package) {
  23962. $this->addPackage($package);
  23963. }
  23964. }
  23965. public function getRepoName()
  23966. {
  23967. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  23968. }
  23969. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  23970. {
  23971. $packages = $this->getPackages();
  23972. $result = array();
  23973. $namesFound = array();
  23974. foreach ($packages as $package) {
  23975. if (array_key_exists($package->getName(), $packageMap)) {
  23976. if (
  23977. (!$packageMap[$package->getName()] || $packageMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  23978. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  23979. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  23980. ) {
  23981. $result[spl_object_hash($package)] = $package;
  23982. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  23983. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  23984. }
  23985. }
  23986. $namesFound[$package->getName()] = true;
  23987. }
  23988. }
  23989. foreach ($packages as $package) {
  23990. if ($package instanceof AliasPackage) {
  23991. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  23992. $result[spl_object_hash($package)] = $package;
  23993. }
  23994. }
  23995. }
  23996. return array('namesFound' => array_keys($namesFound), 'packages' => $result);
  23997. }
  23998. public function findPackage($name, $constraint)
  23999. {
  24000. $name = strtolower($name);
  24001. if (!$constraint instanceof ConstraintInterface) {
  24002. $versionParser = new VersionParser();
  24003. $constraint = $versionParser->parseConstraints($constraint);
  24004. }
  24005. foreach ($this->getPackages() as $package) {
  24006. if ($name === $package->getName()) {
  24007. $pkgConstraint = new Constraint('==', $package->getVersion());
  24008. if ($constraint->matches($pkgConstraint)) {
  24009. return $package;
  24010. }
  24011. }
  24012. }
  24013. return null;
  24014. }
  24015. public function findPackages($name, $constraint = null)
  24016. {
  24017. $name = strtolower($name);
  24018. $packages = array();
  24019. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  24020. $versionParser = new VersionParser();
  24021. $constraint = $versionParser->parseConstraints($constraint);
  24022. }
  24023. foreach ($this->getPackages() as $package) {
  24024. if ($name === $package->getName()) {
  24025. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  24026. $packages[] = $package;
  24027. }
  24028. }
  24029. }
  24030. return $packages;
  24031. }
  24032. public function search($query, $mode = 0, $type = null)
  24033. {
  24034. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  24035. $matches = array();
  24036. foreach ($this->getPackages() as $package) {
  24037. $name = $package->getName();
  24038. if (isset($matches[$name])) {
  24039. continue;
  24040. }
  24041. if (preg_match($regex, $name)
  24042. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  24043. ) {
  24044. if (null !== $type && $package->getType() !== $type) {
  24045. continue;
  24046. }
  24047. $matches[$name] = array(
  24048. 'name' => $package->getPrettyName(),
  24049. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  24050. );
  24051. if ($package instanceof CompletePackageInterface && $package->isAbandoned()) {
  24052. $matches[$name]['abandoned'] = $package->getReplacementPackage() ?: true;
  24053. }
  24054. }
  24055. }
  24056. return array_values($matches);
  24057. }
  24058. public function hasPackage(PackageInterface $package)
  24059. {
  24060. if ($this->packageMap === null) {
  24061. $this->packageMap = array();
  24062. foreach ($this->getPackages() as $repoPackage) {
  24063. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  24064. }
  24065. }
  24066. return isset($this->packageMap[$package->getUniqueName()]);
  24067. }
  24068. public function addPackage(PackageInterface $package)
  24069. {
  24070. if (null === $this->packages) {
  24071. $this->initialize();
  24072. }
  24073. $package->setRepository($this);
  24074. $this->packages[] = $package;
  24075. if ($package instanceof AliasPackage) {
  24076. $aliasedPackage = $package->getAliasOf();
  24077. if (null === $aliasedPackage->getRepository()) {
  24078. $this->addPackage($aliasedPackage);
  24079. }
  24080. }
  24081. $this->packageMap = null;
  24082. }
  24083. public function getProviders($packageName)
  24084. {
  24085. $result = array();
  24086. foreach ($this->getPackages() as $candidate) {
  24087. if (isset($result[$candidate->getName()])) {
  24088. continue;
  24089. }
  24090. foreach ($candidate->getProvides() as $link) {
  24091. if ($packageName === $link->getTarget()) {
  24092. $result[$candidate->getName()] = array(
  24093. 'name' => $candidate->getName(),
  24094. 'description' => $candidate instanceof CompletePackageInterface ? $candidate->getDescription() : null,
  24095. 'type' => $candidate->getType(),
  24096. );
  24097. continue 2;
  24098. }
  24099. }
  24100. }
  24101. return $result;
  24102. }
  24103. protected function createAliasPackage(BasePackage $package, $alias, $prettyAlias)
  24104. {
  24105. while ($package instanceof AliasPackage) {
  24106. $package = $package->getAliasOf();
  24107. }
  24108. if ($package instanceof CompletePackage) {
  24109. return new CompleteAliasPackage($package, $alias, $prettyAlias);
  24110. }
  24111. return new AliasPackage($package, $alias, $prettyAlias);
  24112. }
  24113. public function removePackage(PackageInterface $package)
  24114. {
  24115. $packageId = $package->getUniqueName();
  24116. foreach ($this->getPackages() as $key => $repoPackage) {
  24117. if ($packageId === $repoPackage->getUniqueName()) {
  24118. array_splice($this->packages, $key, 1);
  24119. $this->packageMap = null;
  24120. return;
  24121. }
  24122. }
  24123. }
  24124. public function getPackages()
  24125. {
  24126. if (null === $this->packages) {
  24127. $this->initialize();
  24128. }
  24129. if (null === $this->packages) {
  24130. throw new \LogicException('initialize failed to initialize the packages array');
  24131. }
  24132. return $this->packages;
  24133. }
  24134. #[\ReturnTypeWillChange]
  24135. public function count()
  24136. {
  24137. if (null === $this->packages) {
  24138. $this->initialize();
  24139. }
  24140. return count($this->packages);
  24141. }
  24142. protected function initialize()
  24143. {
  24144. $this->packages = array();
  24145. }
  24146. }
  24147. <?php
  24148. namespace Composer\Repository;
  24149. use Composer\IO\IOInterface;
  24150. use Composer\Json\JsonFile;
  24151. use Composer\Package\BasePackage;
  24152. use Composer\Package\Loader\ArrayLoader;
  24153. use Composer\Package\Loader\LoaderInterface;
  24154. use Composer\Util\Tar;
  24155. use Composer\Util\Zip;
  24156. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  24157. {
  24158. protected $loader;
  24159. protected $lookup;
  24160. protected $repoConfig;
  24161. private $io;
  24162. public function __construct(array $repoConfig, IOInterface $io)
  24163. {
  24164. parent::__construct();
  24165. if (!extension_loaded('zip')) {
  24166. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  24167. }
  24168. $this->loader = new ArrayLoader();
  24169. $this->lookup = $repoConfig['url'];
  24170. $this->io = $io;
  24171. $this->repoConfig = $repoConfig;
  24172. }
  24173. public function getRepoName()
  24174. {
  24175. return 'artifact repo ('.$this->lookup.')';
  24176. }
  24177. public function getRepoConfig()
  24178. {
  24179. return $this->repoConfig;
  24180. }
  24181. protected function initialize()
  24182. {
  24183. parent::initialize();
  24184. $this->scanDirectory($this->lookup);
  24185. }
  24186. private function scanDirectory($path)
  24187. {
  24188. $io = $this->io;
  24189. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  24190. $iterator = new \RecursiveIteratorIterator($directory);
  24191. $regex = new \RegexIterator($iterator, '/^.+\.(zip|phar|tar|gz|tgz)$/i');
  24192. foreach ($regex as $file) {
  24193. if (!$file->isFile()) {
  24194. continue;
  24195. }
  24196. $package = $this->getComposerInformation($file);
  24197. if (!$package) {
  24198. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  24199. continue;
  24200. }
  24201. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  24202. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  24203. $this->addPackage($package);
  24204. }
  24205. }
  24206. private function getComposerInformation(\SplFileInfo $file)
  24207. {
  24208. $json = null;
  24209. $fileType = null;
  24210. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  24211. if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) {
  24212. $fileType = 'tar';
  24213. } elseif ($fileExtension === 'zip') {
  24214. $fileType = 'zip';
  24215. } else {
  24216. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  24217. }
  24218. try {
  24219. if ($fileType === 'tar') {
  24220. $json = Tar::getComposerJson($file->getPathname());
  24221. } else {
  24222. $json = Zip::getComposerJson($file->getPathname());
  24223. }
  24224. } catch (\Exception $exception) {
  24225. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  24226. }
  24227. if (null === $json) {
  24228. return null;
  24229. }
  24230. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  24231. $package['dist'] = array(
  24232. 'type' => $fileType,
  24233. 'url' => strtr($file->getPathname(), '\\', '/'),
  24234. 'shasum' => sha1_file($file->getRealPath()),
  24235. );
  24236. try {
  24237. $package = $this->loader->load($package);
  24238. } catch (\UnexpectedValueException $e) {
  24239. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  24240. }
  24241. return $package;
  24242. }
  24243. }
  24244. <?php
  24245. namespace Composer\Repository;
  24246. use Composer\Package\BasePackage;
  24247. use Composer\Package\Loader\ArrayLoader;
  24248. use Composer\Package\PackageInterface;
  24249. use Composer\Package\AliasPackage;
  24250. use Composer\Package\CompletePackage;
  24251. use Composer\Package\CompleteAliasPackage;
  24252. use Composer\Package\Version\VersionParser;
  24253. use Composer\Package\Version\StabilityFilter;
  24254. use Composer\Json\JsonFile;
  24255. use Composer\Cache;
  24256. use Composer\Config;
  24257. use Composer\IO\IOInterface;
  24258. use Composer\Plugin\PostFileDownloadEvent;
  24259. use Composer\Semver\CompilingMatcher;
  24260. use Composer\Util\HttpDownloader;
  24261. use Composer\Util\Loop;
  24262. use Composer\Plugin\PluginEvents;
  24263. use Composer\Plugin\PreFileDownloadEvent;
  24264. use Composer\EventDispatcher\EventDispatcher;
  24265. use Composer\Downloader\TransportException;
  24266. use Composer\Semver\Constraint\ConstraintInterface;
  24267. use Composer\Semver\Constraint\Constraint;
  24268. use Composer\Semver\Constraint\MatchAllConstraint;
  24269. use Composer\Util\Http\Response;
  24270. use Composer\MetadataMinifier\MetadataMinifier;
  24271. use Composer\Util\Url;
  24272. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  24273. {
  24274. private $repoConfig;
  24275. private $options;
  24276. private $url;
  24277. private $baseUrl;
  24278. private $io;
  24279. private $httpDownloader;
  24280. private $loop;
  24281. protected $cache;
  24282. protected $notifyUrl = null;
  24283. protected $searchUrl = null;
  24284. protected $providersApiUrl = null;
  24285. protected $hasProviders = false;
  24286. protected $providersUrl = null;
  24287. protected $listUrl = null;
  24288. protected $hasAvailablePackageList = false;
  24289. protected $availablePackages = null;
  24290. protected $availablePackagePatterns = null;
  24291. protected $lazyProvidersUrl = null;
  24292. protected $providerListing;
  24293. protected $loader;
  24294. private $allowSslDowngrade = false;
  24295. private $eventDispatcher;
  24296. private $sourceMirrors;
  24297. private $distMirrors;
  24298. private $degradedMode = false;
  24299. private $rootData;
  24300. private $hasPartialPackages = false;
  24301. private $partialPackagesByName = null;
  24302. public $freshMetadataUrls = array();
  24303. public $packagesNotFoundCache = array();
  24304. public $versionParser;
  24305. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null)
  24306. {
  24307. parent::__construct();
  24308. if (!preg_match('{^[\w.]+\??://}', $repoConfig['url'])) {
  24309. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  24310. }
  24311. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  24312. if (strpos($repoConfig['url'], 'https?') === 0) {
  24313. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  24314. }
  24315. $urlBits = parse_url($repoConfig['url']);
  24316. if ($urlBits === false || empty($urlBits['scheme'])) {
  24317. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  24318. }
  24319. if (!isset($repoConfig['options'])) {
  24320. $repoConfig['options'] = array();
  24321. }
  24322. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  24323. $this->allowSslDowngrade = true;
  24324. }
  24325. $this->options = $repoConfig['options'];
  24326. $this->url = $repoConfig['url'];
  24327. if (preg_match('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  24328. $this->url = $match['proto'].'://repo.packagist.org';
  24329. }
  24330. $this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  24331. $this->io = $io;
  24332. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~');
  24333. $this->cache->setReadOnly($config->get('cache-read-only'));
  24334. $this->versionParser = new VersionParser();
  24335. $this->loader = new ArrayLoader($this->versionParser);
  24336. $this->httpDownloader = $httpDownloader;
  24337. $this->eventDispatcher = $eventDispatcher;
  24338. $this->repoConfig = $repoConfig;
  24339. $this->loop = new Loop($this->httpDownloader);
  24340. }
  24341. public function getRepoName()
  24342. {
  24343. return 'composer repo ('.Url::sanitize($this->url).')';
  24344. }
  24345. public function getRepoConfig()
  24346. {
  24347. return $this->repoConfig;
  24348. }
  24349. public function findPackage($name, $constraint)
  24350. {
  24351. $hasProviders = $this->hasProviders();
  24352. $name = strtolower($name);
  24353. if (!$constraint instanceof ConstraintInterface) {
  24354. $constraint = $this->versionParser->parseConstraints($constraint);
  24355. }
  24356. if ($this->lazyProvidersUrl) {
  24357. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  24358. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  24359. }
  24360. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  24361. return null;
  24362. }
  24363. $packages = $this->loadAsyncPackages(array($name => $constraint));
  24364. return reset($packages['packages']);
  24365. }
  24366. if ($hasProviders) {
  24367. foreach ($this->getProviderNames() as $providerName) {
  24368. if ($name === $providerName) {
  24369. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  24370. }
  24371. }
  24372. return null;
  24373. }
  24374. return parent::findPackage($name, $constraint);
  24375. }
  24376. public function findPackages($name, $constraint = null)
  24377. {
  24378. $hasProviders = $this->hasProviders();
  24379. $name = strtolower($name);
  24380. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  24381. $constraint = $this->versionParser->parseConstraints($constraint);
  24382. }
  24383. if ($this->lazyProvidersUrl) {
  24384. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  24385. return $this->filterPackages($this->whatProvides($name), $constraint);
  24386. }
  24387. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  24388. return array();
  24389. }
  24390. $result = $this->loadAsyncPackages(array($name => $constraint));
  24391. return $result['packages'];
  24392. }
  24393. if ($hasProviders) {
  24394. foreach ($this->getProviderNames() as $providerName) {
  24395. if ($name === $providerName) {
  24396. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  24397. }
  24398. }
  24399. return array();
  24400. }
  24401. return parent::findPackages($name, $constraint);
  24402. }
  24403. private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
  24404. {
  24405. if (null === $constraint) {
  24406. if ($returnFirstMatch) {
  24407. return reset($packages);
  24408. }
  24409. return $packages;
  24410. }
  24411. $filteredPackages = array();
  24412. foreach ($packages as $package) {
  24413. $pkgConstraint = new Constraint('==', $package->getVersion());
  24414. if ($constraint->matches($pkgConstraint)) {
  24415. if ($returnFirstMatch) {
  24416. return $package;
  24417. }
  24418. $filteredPackages[] = $package;
  24419. }
  24420. }
  24421. if ($returnFirstMatch) {
  24422. return null;
  24423. }
  24424. return $filteredPackages;
  24425. }
  24426. public function getPackages()
  24427. {
  24428. $hasProviders = $this->hasProviders();
  24429. if ($this->lazyProvidersUrl) {
  24430. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  24431. $packageMap = array();
  24432. foreach ($this->availablePackages as $name) {
  24433. $packageMap[$name] = new MatchAllConstraint();
  24434. }
  24435. $result = $this->loadAsyncPackages($packageMap);
  24436. return array_values($result['packages']);
  24437. }
  24438. if ($this->hasPartialPackages()) {
  24439. return array_values($this->partialPackagesByName);
  24440. }
  24441. 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.');
  24442. }
  24443. if ($hasProviders) {
  24444. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  24445. }
  24446. return parent::getPackages();
  24447. }
  24448. public function getPackageNames($packageFilter = null)
  24449. {
  24450. $hasProviders = $this->hasProviders();
  24451. $packageFilterCb = function ($name) {
  24452. return true;
  24453. };
  24454. if (null !== $packageFilter) {
  24455. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  24456. $packageFilterCb = function ($name) use ($packageFilterRegex) {
  24457. return (bool) preg_match($packageFilterRegex, $name);
  24458. };
  24459. }
  24460. if ($this->lazyProvidersUrl) {
  24461. if (is_array($this->availablePackages)) {
  24462. return array_filter(array_keys($this->availablePackages), $packageFilterCb);
  24463. }
  24464. if ($this->listUrl) {
  24465. $url = $this->listUrl;
  24466. if ($packageFilter) {
  24467. $url .= '?filter='.urlencode($packageFilter);
  24468. }
  24469. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  24470. return $result['packageNames'];
  24471. }
  24472. if ($this->hasPartialPackages()) {
  24473. return array_filter(array_keys($this->partialPackagesByName), $packageFilterCb);
  24474. }
  24475. return array();
  24476. }
  24477. if ($hasProviders) {
  24478. return array_filter($this->getProviderNames(), $packageFilterCb);
  24479. }
  24480. $names = array();
  24481. foreach ($this->getPackages() as $package) {
  24482. if ($packageFilterCb($package->getName())) {
  24483. $names[] = $package->getPrettyName();
  24484. }
  24485. }
  24486. return $names;
  24487. }
  24488. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  24489. {
  24490. $hasProviders = $this->hasProviders();
  24491. if (!$hasProviders && !$this->hasPartialPackages() && !$this->lazyProvidersUrl) {
  24492. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  24493. }
  24494. $packages = array();
  24495. $namesFound = array();
  24496. if ($hasProviders || $this->hasPartialPackages()) {
  24497. foreach ($packageNameMap as $name => $constraint) {
  24498. $matches = array();
  24499. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  24500. continue;
  24501. }
  24502. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  24503. foreach ($candidates as $candidate) {
  24504. if ($candidate->getName() !== $name) {
  24505. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  24506. }
  24507. $namesFound[$name] = true;
  24508. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  24509. $matches[spl_object_hash($candidate)] = $candidate;
  24510. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  24511. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  24512. }
  24513. }
  24514. }
  24515. foreach ($candidates as $candidate) {
  24516. if ($candidate instanceof AliasPackage) {
  24517. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  24518. $matches[spl_object_hash($candidate)] = $candidate;
  24519. }
  24520. }
  24521. }
  24522. $packages = array_merge($packages, $matches);
  24523. unset($packageNameMap[$name]);
  24524. }
  24525. }
  24526. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  24527. if ($this->hasAvailablePackageList) {
  24528. foreach ($packageNameMap as $name => $constraint) {
  24529. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  24530. unset($packageNameMap[$name]);
  24531. }
  24532. }
  24533. }
  24534. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  24535. $packages = array_merge($packages, $result['packages']);
  24536. $namesFound = array_merge($namesFound, $result['namesFound']);
  24537. }
  24538. return array('namesFound' => array_keys($namesFound), 'packages' => $packages);
  24539. }
  24540. public function search($query, $mode = 0, $type = null)
  24541. {
  24542. $this->loadRootServerFile();
  24543. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  24544. $url = str_replace(array('%query%', '%type%'), array($query, $type), $this->searchUrl);
  24545. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  24546. if (empty($search['results'])) {
  24547. return array();
  24548. }
  24549. $results = array();
  24550. foreach ($search['results'] as $result) {
  24551. if (!empty($result['virtual'])) {
  24552. continue;
  24553. }
  24554. $results[] = $result;
  24555. }
  24556. return $results;
  24557. }
  24558. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  24559. $results = array();
  24560. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  24561. foreach ($this->getPackageNames() as $name) {
  24562. if (preg_match($regex, $name)) {
  24563. $results[] = array('name' => $name, 'description' => '');
  24564. }
  24565. }
  24566. return $results;
  24567. }
  24568. return parent::search($query, $mode);
  24569. }
  24570. public function getProviders($packageName)
  24571. {
  24572. $this->loadRootServerFile();
  24573. $result = array();
  24574. if ($this->providersApiUrl) {
  24575. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  24576. foreach ($apiResult['providers'] as $provider) {
  24577. $result[$provider['name']] = $provider;
  24578. }
  24579. return $result;
  24580. }
  24581. if ($this->hasPartialPackages()) {
  24582. foreach ($this->partialPackagesByName as $versions) {
  24583. foreach ($versions as $candidate) {
  24584. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  24585. continue;
  24586. }
  24587. $result[$candidate['name']] = array(
  24588. 'name' => $candidate['name'],
  24589. 'description' => isset($candidate['description']) ? $candidate['description'] : '',
  24590. 'type' => isset($candidate['type']) ? $candidate['type'] : '',
  24591. );
  24592. }
  24593. }
  24594. }
  24595. if ($this->packages) {
  24596. $result = array_merge($result, parent::getProviders($packageName));
  24597. }
  24598. return $result;
  24599. }
  24600. private function getProviderNames()
  24601. {
  24602. $this->loadRootServerFile();
  24603. if (null === $this->providerListing) {
  24604. $this->loadProviderListings($this->loadRootServerFile());
  24605. }
  24606. if ($this->lazyProvidersUrl) {
  24607. return array();
  24608. }
  24609. if ($this->providersUrl) {
  24610. return array_keys($this->providerListing);
  24611. }
  24612. return array();
  24613. }
  24614. protected function configurePackageTransportOptions(PackageInterface $package)
  24615. {
  24616. foreach ($package->getDistUrls() as $url) {
  24617. if (strpos($url, $this->baseUrl) === 0) {
  24618. $package->setTransportOptions($this->options);
  24619. return;
  24620. }
  24621. }
  24622. }
  24623. private function hasProviders()
  24624. {
  24625. $this->loadRootServerFile();
  24626. return $this->hasProviders;
  24627. }
  24628. private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  24629. {
  24630. $packagesSource = null;
  24631. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  24632. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  24633. return array();
  24634. }
  24635. if (null === $this->providerListing) {
  24636. $this->loadProviderListings($this->loadRootServerFile());
  24637. }
  24638. $useLastModifiedCheck = false;
  24639. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  24640. $hash = null;
  24641. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  24642. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  24643. $useLastModifiedCheck = true;
  24644. } elseif ($this->providersUrl) {
  24645. if (!isset($this->providerListing[$name])) {
  24646. return array();
  24647. }
  24648. $hash = $this->providerListing[$name]['sha256'];
  24649. $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $this->providersUrl);
  24650. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  24651. } else {
  24652. return array();
  24653. }
  24654. $packages = null;
  24655. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  24656. $packages = json_decode($this->cache->read($cacheKey), true);
  24657. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  24658. } elseif ($useLastModifiedCheck) {
  24659. if ($contents = $this->cache->read($cacheKey)) {
  24660. $contents = json_decode($contents, true);
  24661. if (isset($alreadyLoaded[$name])) {
  24662. $packages = $contents;
  24663. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  24664. } elseif (isset($contents['last-modified'])) {
  24665. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  24666. $packages = true === $response ? $contents : $response;
  24667. $packagesSource = true === $response ? 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')' : 'downloaded file ('.Url::sanitize($url).')';
  24668. }
  24669. }
  24670. }
  24671. if (!$packages) {
  24672. try {
  24673. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  24674. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  24675. } catch (TransportException $e) {
  24676. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), array(404, 499), true)) {
  24677. $packages = array('packages' => array());
  24678. $packagesSource = 'not-found file ('.Url::sanitize($url).')';
  24679. if ($e->getStatusCode() === 499) {
  24680. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  24681. }
  24682. } else {
  24683. throw $e;
  24684. }
  24685. }
  24686. }
  24687. $loadingPartialPackage = false;
  24688. } else {
  24689. $packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
  24690. $packagesSource = 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')';
  24691. $loadingPartialPackage = true;
  24692. }
  24693. $result = array();
  24694. $versionsToLoad = array();
  24695. foreach ($packages['packages'] as $versions) {
  24696. foreach ($versions as $version) {
  24697. $normalizedName = strtolower($version['name']);
  24698. if ($normalizedName !== $name) {
  24699. continue;
  24700. }
  24701. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  24702. continue;
  24703. }
  24704. if (!isset($versionsToLoad[$version['uid']])) {
  24705. if (!isset($version['version_normalized'])) {
  24706. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  24707. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  24708. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  24709. }
  24710. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  24711. continue;
  24712. }
  24713. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  24714. $versionsToLoad[$version['uid']] = $version;
  24715. }
  24716. }
  24717. }
  24718. }
  24719. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  24720. $uids = array_keys($versionsToLoad);
  24721. foreach ($loadedPackages as $index => $package) {
  24722. $package->setRepository($this);
  24723. $uid = $uids[$index];
  24724. if ($package instanceof AliasPackage) {
  24725. $aliased = $package->getAliasOf();
  24726. $aliased->setRepository($this);
  24727. $result[$uid] = $aliased;
  24728. $result[$uid.'-alias'] = $package;
  24729. } else {
  24730. $result[$uid] = $package;
  24731. }
  24732. }
  24733. return $result;
  24734. }
  24735. protected function initialize()
  24736. {
  24737. parent::initialize();
  24738. $repoData = $this->loadDataFromServer();
  24739. foreach ($this->createPackages($repoData, 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')') as $package) {
  24740. $this->addPackage($package);
  24741. }
  24742. }
  24743. public function addPackage(PackageInterface $package)
  24744. {
  24745. parent::addPackage($package);
  24746. $this->configurePackageTransportOptions($package);
  24747. }
  24748. private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  24749. {
  24750. $this->loadRootServerFile();
  24751. $packages = array();
  24752. $namesFound = array();
  24753. $promises = array();
  24754. $repo = $this;
  24755. if (!$this->lazyProvidersUrl) {
  24756. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  24757. }
  24758. foreach ($packageNames as $name => $constraint) {
  24759. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), 'dev')) {
  24760. $packageNames[$name.'~dev'] = $constraint;
  24761. }
  24762. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  24763. unset($packageNames[$name]);
  24764. }
  24765. }
  24766. foreach ($packageNames as $name => $constraint) {
  24767. $name = strtolower($name);
  24768. $realName = preg_replace('{~dev$}', '', $name);
  24769. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  24770. continue;
  24771. }
  24772. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  24773. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  24774. $lastModified = null;
  24775. if ($contents = $this->cache->read($cacheKey)) {
  24776. $contents = json_decode($contents, true);
  24777. $lastModified = isset($contents['last-modified']) ? $contents['last-modified'] : null;
  24778. }
  24779. $promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
  24780. ->then(function ($response) use (&$packages, &$namesFound, $url, $cacheKey, $contents, $realName, $constraint, $repo, $acceptableStabilities, $stabilityFlags, $alreadyLoaded) {
  24781. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  24782. if (true === $response) {
  24783. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  24784. $response = $contents;
  24785. }
  24786. if (!isset($response['packages'][$realName])) {
  24787. return;
  24788. }
  24789. $versions = $response['packages'][$realName];
  24790. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  24791. $versions = MetadataMinifier::expand($versions);
  24792. }
  24793. $namesFound[$realName] = true;
  24794. $versionsToLoad = array();
  24795. foreach ($versions as $version) {
  24796. if (!isset($version['version_normalized'])) {
  24797. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  24798. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  24799. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  24800. }
  24801. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  24802. continue;
  24803. }
  24804. if ($repo->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  24805. $versionsToLoad[] = $version;
  24806. }
  24807. }
  24808. $loadedPackages = $repo->createPackages($versionsToLoad, $packagesSource);
  24809. foreach ($loadedPackages as $package) {
  24810. $package->setRepository($repo);
  24811. $packages[spl_object_hash($package)] = $package;
  24812. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  24813. $package->getAliasOf()->setRepository($repo);
  24814. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  24815. }
  24816. }
  24817. });
  24818. }
  24819. $this->loop->wait($promises);
  24820. return array('namesFound' => $namesFound, 'packages' => $packages);
  24821. }
  24822. public function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null)
  24823. {
  24824. $versions = array($versionData['version_normalized']);
  24825. if ($alias = $this->loader->getBranchAlias($versionData)) {
  24826. $versions[] = $alias;
  24827. }
  24828. foreach ($versions as $version) {
  24829. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), VersionParser::parseStability($version))) {
  24830. continue;
  24831. }
  24832. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  24833. continue;
  24834. }
  24835. return true;
  24836. }
  24837. return false;
  24838. }
  24839. private function getPackagesJsonUrl()
  24840. {
  24841. $jsonUrlParts = parse_url($this->url);
  24842. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  24843. return $this->url;
  24844. }
  24845. return $this->url . '/packages.json';
  24846. }
  24847. protected function loadRootServerFile()
  24848. {
  24849. if (null !== $this->rootData) {
  24850. return $this->rootData;
  24851. }
  24852. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  24853. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  24854. }
  24855. $data = $this->fetchFile($this->getPackagesJsonUrl(), 'packages.json');
  24856. if (!empty($data['notify-batch'])) {
  24857. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  24858. } elseif (!empty($data['notify'])) {
  24859. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  24860. }
  24861. if (!empty($data['search'])) {
  24862. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  24863. }
  24864. if (!empty($data['mirrors'])) {
  24865. foreach ($data['mirrors'] as $mirror) {
  24866. if (!empty($mirror['git-url'])) {
  24867. $this->sourceMirrors['git'][] = array('url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred']));
  24868. }
  24869. if (!empty($mirror['hg-url'])) {
  24870. $this->sourceMirrors['hg'][] = array('url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred']));
  24871. }
  24872. if (!empty($mirror['dist-url'])) {
  24873. $this->distMirrors[] = array(
  24874. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  24875. 'preferred' => !empty($mirror['preferred']),
  24876. );
  24877. }
  24878. }
  24879. }
  24880. if (!empty($data['providers-lazy-url'])) {
  24881. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  24882. $this->hasProviders = true;
  24883. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  24884. }
  24885. if (!empty($data['metadata-url']) && !empty($data['list']) && $data['metadata-url'] === '/p/%package%.json' && $data['list'] === 'https://packagist.org/packages/list.json') {
  24886. $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>');
  24887. unset($data['metadata-url']);
  24888. }
  24889. if (!empty($data['metadata-url'])) {
  24890. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  24891. $this->providersUrl = null;
  24892. $this->hasProviders = false;
  24893. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  24894. $this->allowSslDowngrade = false;
  24895. if (!empty($data['available-packages'])) {
  24896. $availPackages = array_map('strtolower', $data['available-packages']);
  24897. $this->availablePackages = array_combine($availPackages, $availPackages);
  24898. $this->hasAvailablePackageList = true;
  24899. }
  24900. if (!empty($data['available-package-patterns'])) {
  24901. $this->availablePackagePatterns = array_map(function ($pattern) {
  24902. return BasePackage::packageNameToRegexp($pattern);
  24903. }, $data['available-package-patterns']);
  24904. $this->hasAvailablePackageList = true;
  24905. }
  24906. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  24907. }
  24908. if ($this->allowSslDowngrade) {
  24909. $this->url = str_replace('https://', 'http://', $this->url);
  24910. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  24911. }
  24912. if (!empty($data['providers-url'])) {
  24913. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  24914. $this->hasProviders = true;
  24915. }
  24916. if (!empty($data['list'])) {
  24917. $this->listUrl = $this->canonicalizeUrl($data['list']);
  24918. }
  24919. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  24920. $this->hasProviders = true;
  24921. }
  24922. if (!empty($data['providers-api'])) {
  24923. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  24924. }
  24925. return $this->rootData = $data;
  24926. }
  24927. private function canonicalizeUrl($url)
  24928. {
  24929. if ('/' === $url[0]) {
  24930. if (preg_match('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  24931. return $matches[0] . $url;
  24932. }
  24933. return $this->url;
  24934. }
  24935. return $url;
  24936. }
  24937. private function loadDataFromServer()
  24938. {
  24939. $data = $this->loadRootServerFile();
  24940. return $this->loadIncludes($data);
  24941. }
  24942. private function hasPartialPackages()
  24943. {
  24944. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  24945. $this->initializePartialPackages();
  24946. }
  24947. return $this->hasPartialPackages;
  24948. }
  24949. private function loadProviderListings($data)
  24950. {
  24951. if (isset($data['providers'])) {
  24952. if (!is_array($this->providerListing)) {
  24953. $this->providerListing = array();
  24954. }
  24955. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  24956. }
  24957. if ($this->providersUrl && isset($data['provider-includes'])) {
  24958. $includes = $data['provider-includes'];
  24959. foreach ($includes as $include => $metadata) {
  24960. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  24961. $cacheKey = str_replace(array('%hash%','$'), '', $include);
  24962. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  24963. $includedData = json_decode($this->cache->read($cacheKey), true);
  24964. } else {
  24965. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  24966. }
  24967. $this->loadProviderListings($includedData);
  24968. }
  24969. }
  24970. }
  24971. private function loadIncludes($data)
  24972. {
  24973. $packages = array();
  24974. if (!isset($data['packages']) && !isset($data['includes'])) {
  24975. foreach ($data as $pkg) {
  24976. if (isset($pkg['versions']) && is_array($pkg['versions'])) {
  24977. foreach ($pkg['versions'] as $metadata) {
  24978. $packages[] = $metadata;
  24979. }
  24980. }
  24981. }
  24982. return $packages;
  24983. }
  24984. if (isset($data['packages'])) {
  24985. foreach ($data['packages'] as $package => $versions) {
  24986. foreach ($versions as $version => $metadata) {
  24987. $packages[] = $metadata;
  24988. }
  24989. }
  24990. }
  24991. if (isset($data['includes'])) {
  24992. foreach ($data['includes'] as $include => $metadata) {
  24993. if (isset($metadata['sha1']) && $this->cache->sha1((string) $include) === $metadata['sha1']) {
  24994. $includedData = json_decode($this->cache->read((string) $include), true);
  24995. } else {
  24996. $includedData = $this->fetchFile($include);
  24997. }
  24998. $packages = array_merge($packages, $this->loadIncludes($includedData));
  24999. }
  25000. }
  25001. return $packages;
  25002. }
  25003. public function createPackages(array $packages, $source = null)
  25004. {
  25005. if (!$packages) {
  25006. return array();
  25007. }
  25008. try {
  25009. foreach ($packages as &$data) {
  25010. if (!isset($data['notification-url'])) {
  25011. $data['notification-url'] = $this->notifyUrl;
  25012. }
  25013. }
  25014. $packageInstances = $this->loader->loadPackages($packages);
  25015. foreach ($packageInstances as $package) {
  25016. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  25017. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  25018. }
  25019. $package->setDistMirrors($this->distMirrors);
  25020. $this->configurePackageTransportOptions($package);
  25021. }
  25022. return $packageInstances;
  25023. } catch (\Exception $e) {
  25024. throw new \RuntimeException('Could not load packages '.(isset($packages[0]['name']) ? $packages[0]['name'] : json_encode($packages)).' in '.$this->getRepoName().($source ? ' from '.$source : '').': ['.get_class($e).'] '.$e->getMessage(), 0, $e);
  25025. }
  25026. }
  25027. protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
  25028. {
  25029. if (null === $cacheKey) {
  25030. $cacheKey = $filename;
  25031. $filename = $this->baseUrl.'/'.$filename;
  25032. }
  25033. if (($pos = strpos($filename, '$')) && preg_match('{^https?://}i', $filename)) {
  25034. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  25035. }
  25036. $retries = 3;
  25037. while ($retries--) {
  25038. try {
  25039. $options = $this->options;
  25040. if ($this->eventDispatcher) {
  25041. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
  25042. $preFileDownloadEvent->setTransportOptions($this->options);
  25043. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  25044. $filename = $preFileDownloadEvent->getProcessedUrl();
  25045. $options = $preFileDownloadEvent->getTransportOptions();
  25046. }
  25047. $response = $this->httpDownloader->get($filename, $options);
  25048. $json = (string) $response->getBody();
  25049. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  25050. if ($this->allowSslDowngrade) {
  25051. $this->url = str_replace('http://', 'https://', $this->url);
  25052. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  25053. $filename = str_replace('http://', 'https://', $filename);
  25054. }
  25055. if ($retries) {
  25056. usleep(100000);
  25057. continue;
  25058. }
  25059. 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.');
  25060. }
  25061. if ($this->eventDispatcher) {
  25062. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, $sha256, $filename, 'metadata', array('response' => $response, 'repository' => $this));
  25063. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  25064. }
  25065. $data = $response->decodeJson();
  25066. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  25067. if ($cacheKey && !$this->cache->isReadOnly()) {
  25068. if ($storeLastModifiedTime) {
  25069. $lastModifiedDate = $response->getHeader('last-modified');
  25070. if ($lastModifiedDate) {
  25071. $data['last-modified'] = $lastModifiedDate;
  25072. $json = JsonFile::encode($data, 0);
  25073. }
  25074. }
  25075. $this->cache->write($cacheKey, $json);
  25076. }
  25077. $response->collect();
  25078. break;
  25079. } catch (\Exception $e) {
  25080. if ($e instanceof \LogicException) {
  25081. throw $e;
  25082. }
  25083. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  25084. throw $e;
  25085. }
  25086. if ($e instanceof TransportException && $e->getStatusCode() === null) {
  25087. $responseInfo = $e->getResponseInfo();
  25088. if (isset($responseInfo['namelookup_time']) && $responseInfo['namelookup_time'] == 0) {
  25089. $retries = 0;
  25090. }
  25091. }
  25092. if ($retries) {
  25093. usleep(100000);
  25094. continue;
  25095. }
  25096. if ($e instanceof RepositorySecurityException) {
  25097. throw $e;
  25098. }
  25099. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  25100. if (!$this->degradedMode) {
  25101. $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>');
  25102. }
  25103. $this->degradedMode = true;
  25104. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  25105. break;
  25106. }
  25107. throw $e;
  25108. }
  25109. }
  25110. if (!isset($data)) {
  25111. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  25112. }
  25113. return $data;
  25114. }
  25115. private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime)
  25116. {
  25117. $retries = 3;
  25118. while ($retries--) {
  25119. try {
  25120. $options = $this->options;
  25121. if ($this->eventDispatcher) {
  25122. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
  25123. $preFileDownloadEvent->setTransportOptions($this->options);
  25124. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  25125. $filename = $preFileDownloadEvent->getProcessedUrl();
  25126. $options = $preFileDownloadEvent->getTransportOptions();
  25127. }
  25128. if (isset($options['http']['header'])) {
  25129. $options['http']['header'] = (array) $options['http']['header'];
  25130. }
  25131. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  25132. $response = $this->httpDownloader->get($filename, $options);
  25133. $json = (string) $response->getBody();
  25134. if ($json === '' && $response->getStatusCode() === 304) {
  25135. return true;
  25136. }
  25137. if ($this->eventDispatcher) {
  25138. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', array('response' => $response, 'repository' => $this));
  25139. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  25140. }
  25141. $data = $response->decodeJson();
  25142. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  25143. $lastModifiedDate = $response->getHeader('last-modified');
  25144. $response->collect();
  25145. if ($lastModifiedDate) {
  25146. $data['last-modified'] = $lastModifiedDate;
  25147. $json = JsonFile::encode($data, 0);
  25148. }
  25149. if (!$this->cache->isReadOnly()) {
  25150. $this->cache->write($cacheKey, $json);
  25151. }
  25152. return $data;
  25153. } catch (\Exception $e) {
  25154. if ($e instanceof \LogicException) {
  25155. throw $e;
  25156. }
  25157. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  25158. throw $e;
  25159. }
  25160. if ($retries) {
  25161. usleep(100000);
  25162. continue;
  25163. }
  25164. if (!$this->degradedMode) {
  25165. $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>');
  25166. }
  25167. $this->degradedMode = true;
  25168. return true;
  25169. }
  25170. }
  25171. throw new \LogicException('Should not happen');
  25172. }
  25173. private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null)
  25174. {
  25175. $retries = 3;
  25176. if (isset($this->packagesNotFoundCache[$filename])) {
  25177. return \React\Promise\resolve(array('packages' => array()));
  25178. }
  25179. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  25180. return \React\Promise\resolve(true);
  25181. }
  25182. $httpDownloader = $this->httpDownloader;
  25183. $options = $this->options;
  25184. if ($this->eventDispatcher) {
  25185. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
  25186. $preFileDownloadEvent->setTransportOptions($this->options);
  25187. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  25188. $filename = $preFileDownloadEvent->getProcessedUrl();
  25189. $options = $preFileDownloadEvent->getTransportOptions();
  25190. }
  25191. if ($lastModifiedTime) {
  25192. if (isset($options['http']['header'])) {
  25193. $options['http']['header'] = (array) $options['http']['header'];
  25194. }
  25195. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  25196. }
  25197. $io = $this->io;
  25198. $url = $this->url;
  25199. $cache = $this->cache;
  25200. $degradedMode = &$this->degradedMode;
  25201. $eventDispatcher = $this->eventDispatcher;
  25202. $repo = $this;
  25203. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $eventDispatcher, $repo) {
  25204. if ($response->getStatusCode() === 404) {
  25205. $repo->packagesNotFoundCache[$filename] = true;
  25206. return array('packages' => array());
  25207. }
  25208. $json = (string) $response->getBody();
  25209. if ($json === '' && $response->getStatusCode() === 304) {
  25210. $repo->freshMetadataUrls[$filename] = true;
  25211. return true;
  25212. }
  25213. if ($eventDispatcher) {
  25214. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', array('response' => $response, 'repository' => $repo));
  25215. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  25216. }
  25217. $data = $response->decodeJson();
  25218. HttpDownloader::outputWarnings($io, $url, $data);
  25219. $lastModifiedDate = $response->getHeader('last-modified');
  25220. $response->collect();
  25221. if ($lastModifiedDate) {
  25222. $data['last-modified'] = $lastModifiedDate;
  25223. $json = JsonFile::encode($data, JsonFile::JSON_UNESCAPED_SLASHES | JsonFile::JSON_UNESCAPED_UNICODE);
  25224. }
  25225. if (!$cache->isReadOnly()) {
  25226. $cache->write($cacheKey, $json);
  25227. }
  25228. $repo->freshMetadataUrls[$filename] = true;
  25229. return $data;
  25230. };
  25231. $reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo, $lastModifiedTime) {
  25232. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  25233. $repo->packagesNotFoundCache[$filename] = true;
  25234. return false;
  25235. }
  25236. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  25237. $retries = 0;
  25238. }
  25239. if ($e instanceof TransportException && $e->getStatusCode() === null) {
  25240. $responseInfo = $e->getResponseInfo();
  25241. if (isset($responseInfo['namelookup_time']) && $responseInfo['namelookup_time'] == 0) {
  25242. $retries = 0;
  25243. }
  25244. }
  25245. if (--$retries > 0) {
  25246. usleep(100000);
  25247. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  25248. }
  25249. if (!$degradedMode) {
  25250. $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>');
  25251. }
  25252. $degradedMode = true;
  25253. if ($lastModifiedTime) {
  25254. return $accept(new Response(array('url' => $url), 304, array(), ''));
  25255. }
  25256. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  25257. return $accept(new Response(array('url' => $url), 404, array(), ''));
  25258. }
  25259. throw $e;
  25260. };
  25261. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  25262. }
  25263. private function initializePartialPackages()
  25264. {
  25265. $rootData = $this->loadRootServerFile();
  25266. $this->partialPackagesByName = array();
  25267. foreach ($rootData['packages'] as $package => $versions) {
  25268. foreach ($versions as $version) {
  25269. $this->partialPackagesByName[strtolower($version['name'])][] = $version;
  25270. }
  25271. }
  25272. $this->rootData = true;
  25273. }
  25274. protected function lazyProvidersRepoContains($name)
  25275. {
  25276. if (!$this->hasAvailablePackageList) {
  25277. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  25278. }
  25279. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  25280. return true;
  25281. }
  25282. if (is_array($this->availablePackagePatterns)) {
  25283. foreach ($this->availablePackagePatterns as $providerRegex) {
  25284. if (preg_match($providerRegex, $name)) {
  25285. return true;
  25286. }
  25287. }
  25288. }
  25289. return false;
  25290. }
  25291. }
  25292. <?php
  25293. namespace Composer\Repository;
  25294. use Composer\Package\PackageInterface;
  25295. class CompositeRepository implements RepositoryInterface
  25296. {
  25297. private $repositories;
  25298. public function __construct(array $repositories)
  25299. {
  25300. $this->repositories = array();
  25301. foreach ($repositories as $repo) {
  25302. $this->addRepository($repo);
  25303. }
  25304. }
  25305. public function getRepoName()
  25306. {
  25307. return 'composite repo ('.implode(', ', array_map(function ($repo) {
  25308. return $repo->getRepoName();
  25309. }, $this->repositories)).')';
  25310. }
  25311. public function getRepositories()
  25312. {
  25313. return $this->repositories;
  25314. }
  25315. public function hasPackage(PackageInterface $package)
  25316. {
  25317. foreach ($this->repositories as $repository) {
  25318. if ($repository->hasPackage($package)) {
  25319. return true;
  25320. }
  25321. }
  25322. return false;
  25323. }
  25324. public function findPackage($name, $constraint)
  25325. {
  25326. foreach ($this->repositories as $repository) {
  25327. $package = $repository->findPackage($name, $constraint);
  25328. if (null !== $package) {
  25329. return $package;
  25330. }
  25331. }
  25332. return null;
  25333. }
  25334. public function findPackages($name, $constraint = null)
  25335. {
  25336. $packages = array();
  25337. foreach ($this->repositories as $repository) {
  25338. $packages[] = $repository->findPackages($name, $constraint);
  25339. }
  25340. return $packages ? call_user_func_array('array_merge', $packages) : array();
  25341. }
  25342. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  25343. {
  25344. $packages = array();
  25345. $namesFound = array();
  25346. foreach ($this->repositories as $repository) {
  25347. $result = $repository->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  25348. $packages[] = $result['packages'];
  25349. $namesFound[] = $result['namesFound'];
  25350. }
  25351. return array(
  25352. 'packages' => $packages ? call_user_func_array('array_merge', $packages) : array(),
  25353. 'namesFound' => $namesFound ? array_unique(call_user_func_array('array_merge', $namesFound)) : array(),
  25354. );
  25355. }
  25356. public function search($query, $mode = 0, $type = null)
  25357. {
  25358. $matches = array();
  25359. foreach ($this->repositories as $repository) {
  25360. $matches[] = $repository->search($query, $mode, $type);
  25361. }
  25362. return $matches ? call_user_func_array('array_merge', $matches) : array();
  25363. }
  25364. public function getPackages()
  25365. {
  25366. $packages = array();
  25367. foreach ($this->repositories as $repository) {
  25368. $packages[] = $repository->getPackages();
  25369. }
  25370. return $packages ? call_user_func_array('array_merge', $packages) : array();
  25371. }
  25372. public function getProviders($packageName)
  25373. {
  25374. $results = array();
  25375. foreach ($this->repositories as $repository) {
  25376. $results[] = $repository->getProviders($packageName);
  25377. }
  25378. return $results ? call_user_func_array('array_merge', $results) : array();
  25379. }
  25380. public function removePackage(PackageInterface $package)
  25381. {
  25382. foreach ($this->repositories as $repository) {
  25383. if ($repository instanceof WritableRepositoryInterface) {
  25384. $repository->removePackage($package);
  25385. }
  25386. }
  25387. }
  25388. #[\ReturnTypeWillChange]
  25389. public function count()
  25390. {
  25391. $total = 0;
  25392. foreach ($this->repositories as $repository) {
  25393. $total += $repository->count();
  25394. }
  25395. return $total;
  25396. }
  25397. public function addRepository(RepositoryInterface $repository)
  25398. {
  25399. if ($repository instanceof self) {
  25400. foreach ($repository->getRepositories() as $repo) {
  25401. $this->addRepository($repo);
  25402. }
  25403. } else {
  25404. $this->repositories[] = $repository;
  25405. }
  25406. }
  25407. }
  25408. <?php
  25409. namespace Composer\Repository;
  25410. interface ConfigurableRepositoryInterface
  25411. {
  25412. public function getRepoConfig();
  25413. }
  25414. <?php
  25415. namespace Composer\Repository;
  25416. use Composer\Json\JsonFile;
  25417. use Composer\Package\Loader\ArrayLoader;
  25418. use Composer\Package\RootPackageInterface;
  25419. use Composer\Package\AliasPackage;
  25420. use Composer\Package\Dumper\ArrayDumper;
  25421. use Composer\Installer\InstallationManager;
  25422. use Composer\Util\Filesystem;
  25423. class FilesystemRepository extends WritableArrayRepository
  25424. {
  25425. protected $file;
  25426. private $dumpVersions;
  25427. private $rootPackage;
  25428. private $filesystem;
  25429. public function __construct(JsonFile $repositoryFile, $dumpVersions = false, RootPackageInterface $rootPackage = null, Filesystem $filesystem = null)
  25430. {
  25431. parent::__construct();
  25432. $this->file = $repositoryFile;
  25433. $this->dumpVersions = $dumpVersions;
  25434. $this->rootPackage = $rootPackage;
  25435. $this->filesystem = $filesystem ?: new Filesystem;
  25436. if ($dumpVersions && !$rootPackage) {
  25437. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  25438. }
  25439. }
  25440. protected function initialize()
  25441. {
  25442. parent::initialize();
  25443. if (!$this->file->exists()) {
  25444. return;
  25445. }
  25446. try {
  25447. $data = $this->file->read();
  25448. if (isset($data['packages'])) {
  25449. $packages = $data['packages'];
  25450. } else {
  25451. $packages = $data;
  25452. }
  25453. if (isset($data['dev-package-names'])) {
  25454. $this->setDevPackageNames($data['dev-package-names']);
  25455. }
  25456. if (!is_array($packages)) {
  25457. throw new \UnexpectedValueException('Could not parse package list from the repository');
  25458. }
  25459. } catch (\Exception $e) {
  25460. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  25461. }
  25462. $loader = new ArrayLoader(null, true);
  25463. foreach ($packages as $packageData) {
  25464. $package = $loader->load($packageData);
  25465. $this->addPackage($package);
  25466. }
  25467. }
  25468. public function reload()
  25469. {
  25470. $this->packages = null;
  25471. $this->initialize();
  25472. }
  25473. public function write($devMode, InstallationManager $installationManager)
  25474. {
  25475. $data = array('packages' => array(), 'dev' => $devMode, 'dev-package-names' => array());
  25476. $dumper = new ArrayDumper();
  25477. $repoDir = dirname($this->file->getPath());
  25478. $this->filesystem->ensureDirectoryExists($repoDir);
  25479. $repoDir = $this->filesystem->normalizePath(realpath($repoDir));
  25480. $installPaths = array();
  25481. foreach ($this->getCanonicalPackages() as $package) {
  25482. $pkgArray = $dumper->dump($package);
  25483. $path = $installationManager->getInstallPath($package);
  25484. $installPath = null;
  25485. if ('' !== $path && null !== $path) {
  25486. $normalizedPath = $this->filesystem->normalizePath($this->filesystem->isAbsolutePath($path) ? $path : getcwd() . '/' . $path);
  25487. $installPath = $this->filesystem->findShortestPath($repoDir, $normalizedPath, true);
  25488. }
  25489. $installPaths[$package->getName()] = $installPath;
  25490. $pkgArray['install-path'] = $installPath;
  25491. $data['packages'][] = $pkgArray;
  25492. if (in_array($package->getName(), $this->devPackageNames, true)) {
  25493. $data['dev-package-names'][] = $package->getName();
  25494. }
  25495. }
  25496. sort($data['dev-package-names']);
  25497. usort($data['packages'], function ($a, $b) {
  25498. return strcmp($a['name'], $b['name']);
  25499. });
  25500. $this->file->write($data);
  25501. if ($this->dumpVersions) {
  25502. $versions = $this->generateInstalledVersions($installationManager, $installPaths, $devMode, $repoDir);
  25503. $this->filesystem->filePutContentsIfModified($repoDir.'/installed.php', '<?php return ' . $this->dumpToPhpCode($versions) . ';'."\n");
  25504. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  25505. $this->filesystem->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  25506. \Composer\InstalledVersions::reload($versions);
  25507. }
  25508. }
  25509. private function dumpToPhpCode(array $array = array(), $level = 0)
  25510. {
  25511. $lines = "array(\n";
  25512. $level++;
  25513. foreach ($array as $key => $value) {
  25514. $lines .= str_repeat(' ', $level);
  25515. $lines .= is_int($key) ? $key . ' => ' : '\'' . $key . '\' => ';
  25516. if (is_array($value)) {
  25517. if (!empty($value)) {
  25518. $lines .= $this->dumpToPhpCode($value, $level);
  25519. } else {
  25520. $lines .= "array(),\n";
  25521. }
  25522. } elseif ($key === 'install_path' && is_string($value)) {
  25523. if ($this->filesystem->isAbsolutePath($value)) {
  25524. $lines .= var_export($value, true) . ",\n";
  25525. } else {
  25526. $lines .= "__DIR__ . " . var_export('/' . $value, true) . ",\n";
  25527. }
  25528. } else {
  25529. $lines .= var_export($value, true) . ",\n";
  25530. }
  25531. }
  25532. $lines .= str_repeat(' ', $level - 1) . ')' . ($level - 1 == 0 ? '' : ",\n");
  25533. return $lines;
  25534. }
  25535. private function generateInstalledVersions(InstallationManager $installationManager, array $installPaths, $devMode, $repoDir)
  25536. {
  25537. if (!$this->dumpVersions) {
  25538. return null;
  25539. }
  25540. $devPackages = array_flip($this->devPackageNames);
  25541. $versions = array('versions' => array());
  25542. $packages = $this->getPackages();
  25543. $packages[] = $rootPackage = $this->rootPackage;
  25544. while ($rootPackage instanceof AliasPackage) {
  25545. $rootPackage = $rootPackage->getAliasOf();
  25546. $packages[] = $rootPackage;
  25547. }
  25548. foreach ($packages as $package) {
  25549. if ($package instanceof AliasPackage) {
  25550. continue;
  25551. }
  25552. $reference = null;
  25553. if ($package->getInstallationSource()) {
  25554. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  25555. }
  25556. if (null === $reference) {
  25557. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  25558. }
  25559. if ($package instanceof RootPackageInterface) {
  25560. $to = $this->filesystem->normalizePath(realpath(getcwd()));
  25561. $installPath = $this->filesystem->findShortestPath($repoDir, $to, true);
  25562. } else {
  25563. $installPath = $installPaths[$package->getName()];
  25564. }
  25565. $versions['versions'][$package->getName()] = array(
  25566. 'pretty_version' => $package->getPrettyVersion(),
  25567. 'version' => $package->getVersion(),
  25568. 'type' => $package->getType(),
  25569. 'install_path' => $installPath,
  25570. 'aliases' => array(),
  25571. 'reference' => $reference,
  25572. 'dev_requirement' => isset($devPackages[$package->getName()]),
  25573. );
  25574. if ($package instanceof RootPackageInterface) {
  25575. $versions['root'] = $versions['versions'][$package->getName()];
  25576. unset($versions['root']['dev_requirement']);
  25577. $versions['root']['name'] = $package->getName();
  25578. $versions['root']['dev'] = $devMode;
  25579. }
  25580. }
  25581. foreach ($packages as $package) {
  25582. $isDevPackage = isset($devPackages[$package->getName()]);
  25583. foreach ($package->getReplaces() as $replace) {
  25584. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  25585. continue;
  25586. }
  25587. if (!isset($versions['versions'][$replace->getTarget()]['dev_requirement'])) {
  25588. $versions['versions'][$replace->getTarget()]['dev_requirement'] = $isDevPackage;
  25589. } elseif (!$isDevPackage) {
  25590. $versions['versions'][$replace->getTarget()]['dev_requirement'] = false;
  25591. }
  25592. $replaced = $replace->getPrettyConstraint();
  25593. if ($replaced === 'self.version') {
  25594. $replaced = $package->getPrettyVersion();
  25595. }
  25596. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  25597. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  25598. }
  25599. }
  25600. foreach ($package->getProvides() as $provide) {
  25601. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  25602. continue;
  25603. }
  25604. if (!isset($versions['versions'][$provide->getTarget()]['dev_requirement'])) {
  25605. $versions['versions'][$provide->getTarget()]['dev_requirement'] = $isDevPackage;
  25606. } elseif (!$isDevPackage) {
  25607. $versions['versions'][$provide->getTarget()]['dev_requirement'] = false;
  25608. }
  25609. $provided = $provide->getPrettyConstraint();
  25610. if ($provided === 'self.version') {
  25611. $provided = $package->getPrettyVersion();
  25612. }
  25613. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  25614. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  25615. }
  25616. }
  25617. }
  25618. foreach ($packages as $package) {
  25619. if (!$package instanceof AliasPackage) {
  25620. continue;
  25621. }
  25622. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  25623. if ($package instanceof RootPackageInterface) {
  25624. $versions['root']['aliases'][] = $package->getPrettyVersion();
  25625. }
  25626. }
  25627. ksort($versions['versions']);
  25628. ksort($versions);
  25629. return $versions;
  25630. }
  25631. }
  25632. <?php
  25633. namespace Composer\Repository;
  25634. use Composer\Package\PackageInterface;
  25635. use Composer\Package\BasePackage;
  25636. class FilterRepository implements RepositoryInterface
  25637. {
  25638. private $only = null;
  25639. private $exclude = null;
  25640. private $canonical = true;
  25641. private $repo;
  25642. public function __construct(RepositoryInterface $repo, array $options)
  25643. {
  25644. if (isset($options['only'])) {
  25645. if (!is_array($options['only'])) {
  25646. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  25647. }
  25648. $this->only = '{^(?:'.implode('|', array_map(function ($val) {
  25649. return BasePackage::packageNameToRegexp($val, '%s');
  25650. }, $options['only'])) .')$}iD';
  25651. }
  25652. if (isset($options['exclude'])) {
  25653. if (!is_array($options['exclude'])) {
  25654. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  25655. }
  25656. $this->exclude = '{^(?:'.implode('|', array_map(function ($val) {
  25657. return BasePackage::packageNameToRegexp($val, '%s');
  25658. }, $options['exclude'])) .')$}iD';
  25659. }
  25660. if ($this->exclude && $this->only) {
  25661. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  25662. }
  25663. if (isset($options['canonical'])) {
  25664. if (!is_bool($options['canonical'])) {
  25665. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  25666. }
  25667. $this->canonical = $options['canonical'];
  25668. }
  25669. $this->repo = $repo;
  25670. }
  25671. public function getRepoName()
  25672. {
  25673. return $this->repo->getRepoName();
  25674. }
  25675. public function getRepository()
  25676. {
  25677. return $this->repo;
  25678. }
  25679. public function hasPackage(PackageInterface $package)
  25680. {
  25681. return $this->repo->hasPackage($package);
  25682. }
  25683. public function findPackage($name, $constraint)
  25684. {
  25685. if (!$this->isAllowed($name)) {
  25686. return null;
  25687. }
  25688. return $this->repo->findPackage($name, $constraint);
  25689. }
  25690. public function findPackages($name, $constraint = null)
  25691. {
  25692. if (!$this->isAllowed($name)) {
  25693. return array();
  25694. }
  25695. return $this->repo->findPackages($name, $constraint);
  25696. }
  25697. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  25698. {
  25699. foreach ($packageMap as $name => $constraint) {
  25700. if (!$this->isAllowed($name)) {
  25701. unset($packageMap[$name]);
  25702. }
  25703. }
  25704. if (!$packageMap) {
  25705. return array('namesFound' => array(), 'packages' => array());
  25706. }
  25707. $result = $this->repo->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  25708. if (!$this->canonical) {
  25709. $result['namesFound'] = array();
  25710. }
  25711. return $result;
  25712. }
  25713. public function search($query, $mode = 0, $type = null)
  25714. {
  25715. $result = array();
  25716. foreach ($this->repo->search($query, $mode, $type) as $package) {
  25717. if ($this->isAllowed($package['name'])) {
  25718. $result[] = $package;
  25719. }
  25720. }
  25721. return $result;
  25722. }
  25723. public function getPackages()
  25724. {
  25725. $result = array();
  25726. foreach ($this->repo->getPackages() as $package) {
  25727. if ($this->isAllowed($package->getName())) {
  25728. $result[] = $package;
  25729. }
  25730. }
  25731. return $result;
  25732. }
  25733. public function getProviders($packageName)
  25734. {
  25735. $result = array();
  25736. foreach ($this->repo->getProviders($packageName) as $name => $provider) {
  25737. if ($this->isAllowed($provider['name'])) {
  25738. $result[$name] = $provider;
  25739. }
  25740. }
  25741. return $result;
  25742. }
  25743. #[\ReturnTypeWillChange]
  25744. public function count()
  25745. {
  25746. if ($this->repo->count() > 0) {
  25747. return count($this->getPackages());
  25748. }
  25749. return 0;
  25750. }
  25751. private function isAllowed($name)
  25752. {
  25753. if (!$this->only && !$this->exclude) {
  25754. return true;
  25755. }
  25756. if ($this->only) {
  25757. return (bool) preg_match($this->only, $name);
  25758. }
  25759. return !preg_match($this->exclude, $name);
  25760. }
  25761. }
  25762. <?php
  25763. namespace Composer\Repository;
  25764. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  25765. {
  25766. public function getRepoName()
  25767. {
  25768. return 'installed '.parent::getRepoName();
  25769. }
  25770. public function isFresh()
  25771. {
  25772. return $this->count() === 0;
  25773. }
  25774. }
  25775. <?php
  25776. namespace Composer\Repository;
  25777. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  25778. {
  25779. public function getRepoName()
  25780. {
  25781. return 'installed '.parent::getRepoName();
  25782. }
  25783. public function isFresh()
  25784. {
  25785. return !$this->file->exists();
  25786. }
  25787. }
  25788. <?php
  25789. namespace Composer\Repository;
  25790. use Composer\Package\BasePackage;
  25791. use Composer\Package\PackageInterface;
  25792. use Composer\Package\Version\VersionParser;
  25793. use Composer\Semver\Constraint\ConstraintInterface;
  25794. use Composer\Semver\Constraint\Constraint;
  25795. use Composer\Semver\Constraint\MatchAllConstraint;
  25796. use Composer\Package\RootPackageInterface;
  25797. use Composer\Package\Link;
  25798. class InstalledRepository extends CompositeRepository
  25799. {
  25800. public function findPackagesWithReplacersAndProviders($name, $constraint = null)
  25801. {
  25802. $name = strtolower($name);
  25803. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  25804. $versionParser = new VersionParser();
  25805. $constraint = $versionParser->parseConstraints($constraint);
  25806. }
  25807. $matches = array();
  25808. foreach ($this->getRepositories() as $repo) {
  25809. foreach ($repo->getPackages() as $candidate) {
  25810. if ($name === $candidate->getName()) {
  25811. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  25812. $matches[] = $candidate;
  25813. }
  25814. continue;
  25815. }
  25816. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  25817. if (
  25818. $name === $link->getTarget()
  25819. && ($constraint === null || $constraint->matches($link->getConstraint()))
  25820. ) {
  25821. $matches[] = $candidate;
  25822. continue 2;
  25823. }
  25824. }
  25825. }
  25826. }
  25827. return $matches;
  25828. }
  25829. public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
  25830. {
  25831. $needles = array_map('strtolower', (array) $needle);
  25832. $results = array();
  25833. if (null === $packagesFound) {
  25834. $packagesFound = $needles;
  25835. }
  25836. $rootPackage = null;
  25837. foreach ($this->getPackages() as $package) {
  25838. if ($package instanceof RootPackageInterface) {
  25839. $rootPackage = $package;
  25840. break;
  25841. }
  25842. }
  25843. foreach ($this->getPackages() as $package) {
  25844. $links = $package->getRequires();
  25845. $packagesInTree = $packagesFound;
  25846. if (!$invert) {
  25847. $links += $package->getReplaces();
  25848. foreach ($package->getReplaces() as $link) {
  25849. foreach ($needles as $needle) {
  25850. if ($link->getSource() === $needle) {
  25851. if ($constraint === null || ($link->getConstraint()->matches($constraint) === true)) {
  25852. if (in_array($link->getTarget(), $packagesInTree)) {
  25853. $results[] = array($package, $link, false);
  25854. continue;
  25855. }
  25856. $packagesInTree[] = $link->getTarget();
  25857. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : array();
  25858. $results[] = array($package, $link, $dependents);
  25859. $needles[] = $link->getTarget();
  25860. }
  25861. }
  25862. }
  25863. }
  25864. }
  25865. if ($package instanceof RootPackageInterface) {
  25866. $links += $package->getDevRequires();
  25867. }
  25868. foreach ($links as $link) {
  25869. foreach ($needles as $needle) {
  25870. if ($link->getTarget() === $needle) {
  25871. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  25872. if (in_array($link->getSource(), $packagesInTree)) {
  25873. $results[] = array($package, $link, false);
  25874. continue;
  25875. }
  25876. $packagesInTree[] = $link->getSource();
  25877. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
  25878. $results[] = array($package, $link, $dependents);
  25879. }
  25880. }
  25881. }
  25882. }
  25883. if ($invert && in_array($package->getName(), $needles)) {
  25884. foreach ($package->getConflicts() as $link) {
  25885. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  25886. $version = new Constraint('=', $pkg->getVersion());
  25887. if ($link->getConstraint()->matches($version) === $invert) {
  25888. $results[] = array($package, $link, false);
  25889. }
  25890. }
  25891. }
  25892. }
  25893. foreach ($package->getConflicts() as $link) {
  25894. if (in_array($link->getTarget(), $needles)) {
  25895. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  25896. $version = new Constraint('=', $pkg->getVersion());
  25897. if ($link->getConstraint()->matches($version) === $invert) {
  25898. $results[] = array($package, $link, false);
  25899. }
  25900. }
  25901. }
  25902. }
  25903. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  25904. foreach ($package->getRequires() as $link) {
  25905. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  25906. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  25907. continue;
  25908. }
  25909. $platformPkg = $this->findPackage($link->getTarget(), '*');
  25910. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  25911. $results[] = array($package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false);
  25912. continue;
  25913. }
  25914. foreach ($this->getPackages() as $pkg) {
  25915. if (!in_array($link->getTarget(), $pkg->getNames())) {
  25916. continue;
  25917. }
  25918. $version = new Constraint('=', $pkg->getVersion());
  25919. if ($link->getTarget() !== $pkg->getName()) {
  25920. foreach (array_merge($pkg->getReplaces(), $pkg->getProvides()) as $prov) {
  25921. if ($link->getTarget() === $prov->getTarget()) {
  25922. $version = $prov->getConstraint();
  25923. break;
  25924. }
  25925. }
  25926. }
  25927. if (!$link->getConstraint()->matches($version)) {
  25928. if ($rootPackage) {
  25929. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  25930. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  25931. $results[] = array($package, $link, false);
  25932. $results[] = array($rootPackage, $rootReq, false);
  25933. continue 3;
  25934. }
  25935. }
  25936. $results[] = array($package, $link, false);
  25937. $results[] = array($rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_DOES_NOT_REQUIRE, 'but ' . $pkg->getPrettyVersion() . ' is installed'), false);
  25938. } else {
  25939. $results[] = array($package, $link, false);
  25940. }
  25941. }
  25942. continue 2;
  25943. }
  25944. }
  25945. }
  25946. }
  25947. ksort($results);
  25948. return $results;
  25949. }
  25950. public function getRepoName()
  25951. {
  25952. return 'installed repo ('.implode(', ', array_map(function ($repo) {
  25953. return $repo->getRepoName();
  25954. }, $this->getRepositories())).')';
  25955. }
  25956. public function addRepository(RepositoryInterface $repository)
  25957. {
  25958. if (
  25959. $repository instanceof LockArrayRepository
  25960. || $repository instanceof InstalledRepositoryInterface
  25961. || $repository instanceof RootPackageRepository
  25962. || $repository instanceof PlatformRepository
  25963. ) {
  25964. parent::addRepository($repository);
  25965. return;
  25966. }
  25967. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  25968. }
  25969. }
  25970. <?php
  25971. namespace Composer\Repository;
  25972. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  25973. {
  25974. public function isFresh();
  25975. }
  25976. <?php
  25977. namespace Composer\Repository;
  25978. class InvalidRepositoryException extends \Exception
  25979. {
  25980. }
  25981. <?php
  25982. namespace Composer\Repository;
  25983. class LockArrayRepository extends ArrayRepository
  25984. {
  25985. public function getRepoName()
  25986. {
  25987. return 'lock repo';
  25988. }
  25989. }
  25990. <?php
  25991. namespace Composer\Repository;
  25992. use Composer\Package\Loader\ArrayLoader;
  25993. use Composer\Package\Loader\ValidatingArrayLoader;
  25994. class PackageRepository extends ArrayRepository
  25995. {
  25996. private $config;
  25997. public function __construct(array $config)
  25998. {
  25999. parent::__construct();
  26000. $this->config = $config['package'];
  26001. if (!is_numeric(key($this->config))) {
  26002. $this->config = array($this->config);
  26003. }
  26004. }
  26005. protected function initialize()
  26006. {
  26007. parent::initialize();
  26008. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), false);
  26009. foreach ($this->config as $package) {
  26010. try {
  26011. $package = $loader->load($package);
  26012. } catch (\Exception $e) {
  26013. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  26014. }
  26015. $this->addPackage($package);
  26016. }
  26017. }
  26018. public function getRepoName()
  26019. {
  26020. return preg_replace('{^array }', 'package ', parent::getRepoName());
  26021. }
  26022. }
  26023. <?php
  26024. namespace Composer\Repository;
  26025. use Composer\Config;
  26026. use Composer\IO\IOInterface;
  26027. use Composer\Json\JsonFile;
  26028. use Composer\Package\Loader\ArrayLoader;
  26029. use Composer\Package\Version\VersionGuesser;
  26030. use Composer\Package\Version\VersionParser;
  26031. use Composer\Util\Platform;
  26032. use Composer\Util\ProcessExecutor;
  26033. use Composer\Util\Filesystem;
  26034. use Composer\Util\Url;
  26035. use Composer\Util\Git as GitUtil;
  26036. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  26037. {
  26038. private $loader;
  26039. private $versionGuesser;
  26040. private $url;
  26041. private $repoConfig;
  26042. private $process;
  26043. private $options;
  26044. public function __construct(array $repoConfig, IOInterface $io, Config $config)
  26045. {
  26046. if (!isset($repoConfig['url'])) {
  26047. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  26048. }
  26049. $this->loader = new ArrayLoader(null, true);
  26050. $this->url = Platform::expandPath($repoConfig['url']);
  26051. $this->process = new ProcessExecutor($io);
  26052. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  26053. $this->repoConfig = $repoConfig;
  26054. $this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
  26055. if (!isset($this->options['relative'])) {
  26056. $filesystem = new Filesystem();
  26057. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  26058. }
  26059. parent::__construct();
  26060. }
  26061. public function getRepoName()
  26062. {
  26063. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  26064. }
  26065. public function getRepoConfig()
  26066. {
  26067. return $this->repoConfig;
  26068. }
  26069. protected function initialize()
  26070. {
  26071. parent::initialize();
  26072. $urlMatches = $this->getUrlMatches();
  26073. if (empty($urlMatches)) {
  26074. if (preg_match('{[*{}]}', $this->url)) {
  26075. $url = $this->url;
  26076. while (preg_match('{[*{}]}', $url)) {
  26077. $url = dirname($url);
  26078. }
  26079. if (is_dir($url)) {
  26080. return;
  26081. }
  26082. }
  26083. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  26084. }
  26085. foreach ($urlMatches as $url) {
  26086. $path = realpath($url) . DIRECTORY_SEPARATOR;
  26087. $composerFilePath = $path.'composer.json';
  26088. if (!file_exists($composerFilePath)) {
  26089. continue;
  26090. }
  26091. $json = file_get_contents($composerFilePath);
  26092. $package = JsonFile::parseJson($json, $composerFilePath);
  26093. $package['dist'] = array(
  26094. 'type' => 'path',
  26095. 'url' => $url,
  26096. 'reference' => sha1($json . serialize($this->options)),
  26097. );
  26098. $package['transport-options'] = $this->options;
  26099. unset($package['transport-options']['versions']);
  26100. if (isset($package['name'], $this->options['versions'][$package['name']])) {
  26101. $package['version'] = $this->options['versions'][$package['name']];
  26102. }
  26103. if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) {
  26104. if (
  26105. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  26106. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  26107. && $ref1 === $ref2
  26108. ) {
  26109. $package['version'] = $rootVersion;
  26110. }
  26111. }
  26112. $output = '';
  26113. if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H'.GitUtil::getNoShowSignatureFlag($this->process), $output, $path)) {
  26114. $package['dist']['reference'] = trim($output);
  26115. }
  26116. if (!isset($package['version'])) {
  26117. $versionData = $this->versionGuesser->guessVersion($package, $path);
  26118. if (is_array($versionData) && $versionData['pretty_version']) {
  26119. if (!empty($versionData['feature_pretty_version'])) {
  26120. $package['version'] = $versionData['feature_pretty_version'];
  26121. $this->addPackage($this->loader->load($package));
  26122. }
  26123. $package['version'] = $versionData['pretty_version'];
  26124. } else {
  26125. $package['version'] = 'dev-master';
  26126. }
  26127. }
  26128. $package = $this->loader->load($package);
  26129. $this->addPackage($package);
  26130. }
  26131. }
  26132. private function getUrlMatches()
  26133. {
  26134. $flags = GLOB_MARK | GLOB_ONLYDIR;
  26135. if (defined('GLOB_BRACE')) {
  26136. $flags |= GLOB_BRACE;
  26137. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  26138. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  26139. }
  26140. return array_map(function ($val) {
  26141. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  26142. }, glob($this->url, $flags));
  26143. }
  26144. }
  26145. <?php
  26146. namespace Composer\Repository;
  26147. class PearRepository extends ArrayRepository
  26148. {
  26149. public function __construct()
  26150. {
  26151. throw new \InvalidArgumentException('The PEAR repository has been removed from Composer 2.x');
  26152. }
  26153. }
  26154. <?php
  26155. namespace Composer\Repository;
  26156. use Composer\Composer;
  26157. use Composer\Package\CompletePackage;
  26158. use Composer\Package\CompletePackageInterface;
  26159. use Composer\Package\Link;
  26160. use Composer\Package\PackageInterface;
  26161. use Composer\Package\Version\VersionParser;
  26162. use Composer\Platform\HhvmDetector;
  26163. use Composer\Platform\Runtime;
  26164. use Composer\Platform\Version;
  26165. use Composer\Plugin\PluginInterface;
  26166. use Composer\Semver\Constraint\Constraint;
  26167. use Composer\Util\Silencer;
  26168. use Composer\XdebugHandler\XdebugHandler;
  26169. class PlatformRepository extends ArrayRepository
  26170. {
  26171. const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-(?:plugin|runtime)-api)$}iD';
  26172. private static $lastSeenPlatformPhp = null;
  26173. private $versionParser;
  26174. private $overrides = array();
  26175. private $runtime;
  26176. private $hhvmDetector;
  26177. public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)
  26178. {
  26179. $this->runtime = $runtime ?: new Runtime();
  26180. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  26181. foreach ($overrides as $name => $version) {
  26182. $this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
  26183. }
  26184. parent::__construct($packages);
  26185. }
  26186. public function getRepoName()
  26187. {
  26188. return 'platform repo';
  26189. }
  26190. protected function initialize()
  26191. {
  26192. parent::initialize();
  26193. $this->versionParser = new VersionParser();
  26194. foreach ($this->overrides as $override) {
  26195. if (!self::isPlatformPackage($override['name'])) {
  26196. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  26197. }
  26198. $this->addOverriddenPackage($override);
  26199. }
  26200. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  26201. $version = $this->versionParser->normalize($prettyVersion);
  26202. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  26203. $composerPluginApi->setDescription('The Composer Plugin API');
  26204. $this->addPackage($composerPluginApi);
  26205. $prettyVersion = Composer::RUNTIME_API_VERSION;
  26206. $version = $this->versionParser->normalize($prettyVersion);
  26207. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  26208. $composerRuntimeApi->setDescription('The Composer Runtime API');
  26209. $this->addPackage($composerRuntimeApi);
  26210. try {
  26211. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  26212. $version = $this->versionParser->normalize($prettyVersion);
  26213. } catch (\UnexpectedValueException $e) {
  26214. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  26215. $version = $this->versionParser->normalize($prettyVersion);
  26216. }
  26217. $php = new CompletePackage('php', $version, $prettyVersion);
  26218. $php->setDescription('The PHP interpreter');
  26219. $this->addPackage($php);
  26220. if ($this->runtime->getConstant('PHP_DEBUG')) {
  26221. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  26222. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  26223. $this->addPackage($phpdebug);
  26224. }
  26225. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  26226. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  26227. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  26228. $this->addPackage($phpzts);
  26229. }
  26230. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  26231. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  26232. $php64->setDescription('The PHP interpreter, 64bit');
  26233. $this->addPackage($php64);
  26234. }
  26235. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call(array($this->runtime, 'invoke'), 'inet_pton', array('::')) !== false) {
  26236. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  26237. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  26238. $this->addPackage($phpIpv6);
  26239. }
  26240. $loadedExtensions = $this->runtime->getExtensions();
  26241. foreach ($loadedExtensions as $name) {
  26242. if (in_array($name, array('standard', 'Core'))) {
  26243. continue;
  26244. }
  26245. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  26246. }
  26247. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  26248. $this->addExtension('xdebug', $prettyVersion);
  26249. }
  26250. foreach ($loadedExtensions as $name) {
  26251. switch ($name) {
  26252. case 'amqp':
  26253. $info = $this->runtime->getExtensionInfo($name);
  26254. if (preg_match('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  26255. $this->addLibrary($name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  26256. }
  26257. if (preg_match('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  26258. $this->addLibrary($name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  26259. }
  26260. break;
  26261. case 'bz2':
  26262. $info = $this->runtime->getExtensionInfo($name);
  26263. if (preg_match('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  26264. $this->addLibrary($name, $matches['version']);
  26265. }
  26266. break;
  26267. case 'curl':
  26268. $curlVersion = $this->runtime->invoke('curl_version');
  26269. $this->addLibrary($name, $curlVersion['version']);
  26270. $info = $this->runtime->getExtensionInfo($name);
  26271. if (preg_match('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  26272. $library = strtolower($sslMatches['library']);
  26273. if ($library === 'openssl') {
  26274. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  26275. $this->addLibrary($name.'-openssl'.($isFips ? '-fips' : ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl') : array());
  26276. } else {
  26277. $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl'));
  26278. }
  26279. }
  26280. if (preg_match('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  26281. $this->addLibrary($name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  26282. }
  26283. if (preg_match('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  26284. $this->addLibrary($name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  26285. }
  26286. break;
  26287. case 'date':
  26288. $info = $this->runtime->getExtensionInfo($name);
  26289. if (preg_match('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  26290. $this->addLibrary($name.'-timelib', $timelibMatches['version'], 'date timelib version');
  26291. }
  26292. if (preg_match('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  26293. $external = $zoneinfoSourceMatches['source'] === 'external';
  26294. if (preg_match('/^"Olson" Timezone Database Version => (?<version>.+?)(\.system)?$/im', $info, $zoneinfoMatches)) {
  26295. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  26296. $this->addLibrary('timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', array($name.'-zoneinfo'));
  26297. } else {
  26298. $this->addLibrary($name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  26299. }
  26300. }
  26301. }
  26302. break;
  26303. case 'fileinfo':
  26304. $info = $this->runtime->getExtensionInfo($name);
  26305. if (preg_match('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  26306. $this->addLibrary($name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  26307. }
  26308. break;
  26309. case 'gd':
  26310. $this->addLibrary($name, $this->runtime->getConstant('GD_VERSION'));
  26311. $info = $this->runtime->getExtensionInfo($name);
  26312. if (preg_match('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  26313. $this->addLibrary($name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  26314. }
  26315. if (preg_match('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  26316. $this->addLibrary($name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  26317. }
  26318. if (preg_match('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  26319. $this->addLibrary($name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  26320. }
  26321. if (preg_match('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  26322. $this->addLibrary($name.'-libxpm', Version::convertLibxpmVersionId($libxpmMatches['versionId']), 'libxpm version for gd');
  26323. }
  26324. break;
  26325. case 'gmp':
  26326. $this->addLibrary($name, $this->runtime->getConstant('GMP_VERSION'));
  26327. break;
  26328. case 'iconv':
  26329. $this->addLibrary($name, $this->runtime->getConstant('ICONV_VERSION'));
  26330. break;
  26331. case 'intl':
  26332. $info = $this->runtime->getExtensionInfo($name);
  26333. $description = 'The ICU unicode and globalization support library';
  26334. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  26335. $this->addLibrary('icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  26336. } elseif (preg_match('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  26337. $this->addLibrary('icu', $matches['version'], $description);
  26338. }
  26339. if (preg_match('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches)) {
  26340. $this->addLibrary('icu-zoneinfo', Version::parseZoneinfoVersion($zoneinfoMatches['version']), 'zoneinfo ("Olson") database for icu');
  26341. }
  26342. if ($this->runtime->hasClass('ResourceBundle')) {
  26343. $cldrVersion = $this->runtime->invoke(array('ResourceBundle', 'create'), array('root', 'ICUDATA', false))->get('Version');
  26344. $this->addLibrary('icu-cldr', $cldrVersion, 'ICU CLDR project version');
  26345. }
  26346. if ($this->runtime->hasClass('IntlChar')) {
  26347. $this->addLibrary('icu-unicode', implode('.', array_slice($this->runtime->invoke(array('IntlChar', 'getUnicodeVersion')), 0, 3)), 'ICU unicode version');
  26348. }
  26349. break;
  26350. case 'imagick':
  26351. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  26352. preg_match('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches);
  26353. $version = $matches['version'];
  26354. if (isset($matches['patch'])) {
  26355. $version .= '.'.$matches['patch'];
  26356. }
  26357. $this->addLibrary($name.'-imagemagick', $version, null, array('imagick'));
  26358. break;
  26359. case 'ldap':
  26360. $info = $this->runtime->getExtensionInfo($name);
  26361. if (preg_match('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && preg_match('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  26362. $this->addLibrary($name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId($matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  26363. }
  26364. break;
  26365. case 'libxml':
  26366. $libxmlProvides = array_map(function ($extension) {
  26367. return $extension . '-libxml';
  26368. }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter')));
  26369. $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides);
  26370. break;
  26371. case 'mbstring':
  26372. $info = $this->runtime->getExtensionInfo($name);
  26373. if (preg_match('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  26374. $this->addLibrary($name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  26375. }
  26376. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  26377. $this->addLibrary($name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  26378. } elseif (preg_match('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  26379. $this->addLibrary($name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  26380. }
  26381. break;
  26382. case 'memcached':
  26383. $info = $this->runtime->getExtensionInfo($name);
  26384. if (preg_match('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  26385. $this->addLibrary($name.'-libmemcached', $matches['version'], 'libmemcached version');
  26386. }
  26387. break;
  26388. case 'openssl':
  26389. if (preg_match('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  26390. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  26391. $this->addLibrary($name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), array(), $isFips ? array($name) : array());
  26392. }
  26393. break;
  26394. case 'pcre':
  26395. $this->addLibrary($name, preg_replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  26396. $info = $this->runtime->getExtensionInfo($name);
  26397. if (preg_match('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  26398. $this->addLibrary($name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  26399. }
  26400. break;
  26401. case 'mysqlnd':
  26402. case 'pdo_mysql':
  26403. $info = $this->runtime->getExtensionInfo($name);
  26404. if (preg_match('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  26405. $this->addLibrary($name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  26406. }
  26407. break;
  26408. case 'mongodb':
  26409. $info = $this->runtime->getExtensionInfo($name);
  26410. if (preg_match('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  26411. $this->addLibrary($name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  26412. }
  26413. if (preg_match('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  26414. $this->addLibrary($name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  26415. }
  26416. break;
  26417. case 'pgsql':
  26418. case 'pdo_pgsql':
  26419. $info = $this->runtime->getExtensionInfo($name);
  26420. if (preg_match('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  26421. $this->addLibrary($name.'-libpq', $matches['version'], 'libpq for '.$name);
  26422. }
  26423. break;
  26424. case 'libsodium':
  26425. case 'sodium':
  26426. if ($this->runtime->hasConstant('SODIUM_LIBRARY_VERSION')) {
  26427. $this->addLibrary('libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  26428. }
  26429. break;
  26430. case 'sqlite3':
  26431. case 'pdo_sqlite':
  26432. $info = $this->runtime->getExtensionInfo($name);
  26433. if (preg_match('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  26434. $this->addLibrary($name.'-sqlite', $matches['version']);
  26435. }
  26436. break;
  26437. case 'ssh2':
  26438. $info = $this->runtime->getExtensionInfo($name);
  26439. if (preg_match('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  26440. $this->addLibrary($name.'-libssh2', $matches['version']);
  26441. }
  26442. break;
  26443. case 'xsl':
  26444. $this->addLibrary('libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, array('xsl'));
  26445. $info = $this->runtime->getExtensionInfo('xsl');
  26446. if (preg_match('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  26447. $this->addLibrary('libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  26448. }
  26449. break;
  26450. case 'yaml':
  26451. $info = $this->runtime->getExtensionInfo('yaml');
  26452. if (preg_match('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  26453. $this->addLibrary($name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  26454. }
  26455. break;
  26456. case 'zip':
  26457. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  26458. $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION', 'ZipArchive'), null, array('zip'));
  26459. }
  26460. break;
  26461. case 'zlib':
  26462. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  26463. $this->addLibrary($name, $this->runtime->getConstant('ZLIB_VERSION'));
  26464. } elseif (preg_match('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  26465. $this->addLibrary($name, $matches['version']);
  26466. }
  26467. break;
  26468. default:
  26469. break;
  26470. }
  26471. }
  26472. $hhvmVersion = $this->hhvmDetector->getVersion();
  26473. if ($hhvmVersion) {
  26474. try {
  26475. $prettyVersion = $hhvmVersion;
  26476. $version = $this->versionParser->normalize($prettyVersion);
  26477. } catch (\UnexpectedValueException $e) {
  26478. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  26479. $version = $this->versionParser->normalize($prettyVersion);
  26480. }
  26481. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  26482. $hhvm->setDescription('The HHVM Runtime (64bit)');
  26483. $this->addPackage($hhvm);
  26484. }
  26485. }
  26486. public function addPackage(PackageInterface $package)
  26487. {
  26488. if (isset($this->overrides[$package->getName()])) {
  26489. $overrider = $this->findPackage($package->getName(), '*');
  26490. if ($package->getVersion() === $overrider->getVersion()) {
  26491. $actualText = 'same as actual';
  26492. } else {
  26493. $actualText = 'actual: '.$package->getPrettyVersion();
  26494. }
  26495. if ($overrider instanceof CompletePackageInterface) {
  26496. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  26497. }
  26498. return;
  26499. }
  26500. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  26501. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  26502. if ($package->getVersion() === $overrider->getVersion()) {
  26503. $actualText = 'same as actual';
  26504. } else {
  26505. $actualText = 'actual: '.$package->getPrettyVersion();
  26506. }
  26507. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  26508. return;
  26509. }
  26510. parent::addPackage($package);
  26511. }
  26512. private function addOverriddenPackage(array $override, $name = null)
  26513. {
  26514. $version = $this->versionParser->normalize($override['version']);
  26515. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  26516. $package->setDescription('Package overridden via config.platform');
  26517. $package->setExtra(array('config.platform' => true));
  26518. parent::addPackage($package);
  26519. if ($package->getName() === 'php') {
  26520. self::$lastSeenPlatformPhp = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  26521. }
  26522. return $package;
  26523. }
  26524. private function addExtension($name, $prettyVersion)
  26525. {
  26526. $extraDescription = null;
  26527. try {
  26528. $version = $this->versionParser->normalize($prettyVersion);
  26529. } catch (\UnexpectedValueException $e) {
  26530. $extraDescription = ' (actual version: '.$prettyVersion.')';
  26531. if (preg_match('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  26532. $prettyVersion = $match[1];
  26533. } else {
  26534. $prettyVersion = '0';
  26535. }
  26536. $version = $this->versionParser->normalize($prettyVersion);
  26537. }
  26538. $packageName = $this->buildPackageName($name);
  26539. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  26540. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  26541. if ($name === 'uuid') {
  26542. $ext->setReplaces(array(
  26543. 'lib-uuid' => new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()),
  26544. ));
  26545. }
  26546. $this->addPackage($ext);
  26547. }
  26548. private function buildPackageName($name)
  26549. {
  26550. return 'ext-' . str_replace(' ', '-', strtolower($name));
  26551. }
  26552. private function addLibrary($name, $prettyVersion, $description = null, array $replaces = array(), array $provides = array())
  26553. {
  26554. try {
  26555. $version = $this->versionParser->normalize($prettyVersion);
  26556. } catch (\UnexpectedValueException $e) {
  26557. return;
  26558. }
  26559. if ($description === null) {
  26560. $description = 'The '.$name.' library';
  26561. }
  26562. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  26563. $lib->setDescription($description);
  26564. $links = function ($alias) use ($name, $version, $lib) {
  26565. return new Link('lib-'.$name, 'lib-'.$alias, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  26566. };
  26567. $lib->setReplaces(array_map($links, $replaces));
  26568. $lib->setProvides(array_map($links, $provides));
  26569. $this->addPackage($lib);
  26570. }
  26571. public static function isPlatformPackage($name)
  26572. {
  26573. static $cache = array();
  26574. if (isset($cache[$name])) {
  26575. return $cache[$name];
  26576. }
  26577. return $cache[$name] = (bool) preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  26578. }
  26579. public static function getPlatformPhpVersion()
  26580. {
  26581. return self::$lastSeenPlatformPhp;
  26582. }
  26583. }
  26584. <?php
  26585. namespace Composer\Repository;
  26586. use Composer\Factory;
  26587. use Composer\IO\IOInterface;
  26588. use Composer\Config;
  26589. use Composer\EventDispatcher\EventDispatcher;
  26590. use Composer\Util\HttpDownloader;
  26591. use Composer\Util\ProcessExecutor;
  26592. use Composer\Json\JsonFile;
  26593. class RepositoryFactory
  26594. {
  26595. public static function configFromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
  26596. {
  26597. if (0 === strpos($repository, 'http')) {
  26598. $repoConfig = array('type' => 'composer', 'url' => $repository);
  26599. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  26600. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  26601. $data = $json->read();
  26602. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  26603. $repoConfig = array('type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/'));
  26604. } elseif ($allowFilesystem) {
  26605. $repoConfig = array('type' => 'filesystem', 'json' => $json);
  26606. } else {
  26607. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  26608. }
  26609. } elseif (strpos($repository, '{') === 0) {
  26610. $repoConfig = JsonFile::parseJson($repository);
  26611. } else {
  26612. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  26613. }
  26614. return $repoConfig;
  26615. }
  26616. public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null)
  26617. {
  26618. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  26619. return static::createRepo($io, $config, $repoConfig, $rm);
  26620. }
  26621. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
  26622. {
  26623. if (!$rm) {
  26624. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  26625. }
  26626. $repos = static::createRepos($rm, array($repoConfig));
  26627. return reset($repos);
  26628. }
  26629. public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
  26630. {
  26631. if (!$config) {
  26632. $config = Factory::createConfig($io);
  26633. }
  26634. if ($io) {
  26635. $io->loadConfiguration($config);
  26636. }
  26637. if (!$rm) {
  26638. if (!$io) {
  26639. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  26640. }
  26641. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  26642. }
  26643. return static::createRepos($rm, $config->getRepositories());
  26644. }
  26645. public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  26646. {
  26647. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  26648. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  26649. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  26650. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  26651. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  26652. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  26653. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  26654. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  26655. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  26656. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  26657. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  26658. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  26659. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  26660. $rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository');
  26661. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  26662. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  26663. return $rm;
  26664. }
  26665. private static function createRepos(RepositoryManager $rm, array $repoConfigs)
  26666. {
  26667. $repos = array();
  26668. foreach ($repoConfigs as $index => $repo) {
  26669. if (is_string($repo)) {
  26670. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  26671. }
  26672. if (!is_array($repo)) {
  26673. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  26674. }
  26675. if (!isset($repo['type'])) {
  26676. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  26677. }
  26678. $name = self::generateRepositoryName($index, $repo, $repos);
  26679. if ($repo['type'] === 'filesystem') {
  26680. $repos[$name] = new FilesystemRepository($repo['json']);
  26681. } else {
  26682. $repos[$name] = $rm->createRepository($repo['type'], $repo, $index);
  26683. }
  26684. }
  26685. return $repos;
  26686. }
  26687. public static function generateRepositoryName($index, array $repo, array $existingRepos)
  26688. {
  26689. $name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
  26690. while (isset($existingRepos[$name])) {
  26691. $name .= '2';
  26692. }
  26693. return $name;
  26694. }
  26695. }
  26696. <?php
  26697. namespace Composer\Repository;
  26698. use Composer\Package\PackageInterface;
  26699. use Composer\Package\BasePackage;
  26700. use Composer\Semver\Constraint\ConstraintInterface;
  26701. interface RepositoryInterface extends \Countable
  26702. {
  26703. const SEARCH_FULLTEXT = 0;
  26704. const SEARCH_NAME = 1;
  26705. public function hasPackage(PackageInterface $package);
  26706. public function findPackage($name, $constraint);
  26707. public function findPackages($name, $constraint = null);
  26708. public function getPackages();
  26709. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array());
  26710. public function search($query, $mode = 0, $type = null);
  26711. public function getProviders($packageName);
  26712. public function getRepoName();
  26713. }
  26714. <?php
  26715. namespace Composer\Repository;
  26716. use Composer\IO\IOInterface;
  26717. use Composer\Config;
  26718. use Composer\EventDispatcher\EventDispatcher;
  26719. use Composer\Package\PackageInterface;
  26720. use Composer\Util\HttpDownloader;
  26721. use Composer\Util\ProcessExecutor;
  26722. class RepositoryManager
  26723. {
  26724. private $localRepository;
  26725. private $repositories = array();
  26726. private $repositoryClasses = array();
  26727. private $io;
  26728. private $config;
  26729. private $httpDownloader;
  26730. private $eventDispatcher;
  26731. private $process;
  26732. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  26733. {
  26734. $this->io = $io;
  26735. $this->config = $config;
  26736. $this->httpDownloader = $httpDownloader;
  26737. $this->eventDispatcher = $eventDispatcher;
  26738. $this->process = $process ?: new ProcessExecutor($io);
  26739. }
  26740. public function findPackage($name, $constraint)
  26741. {
  26742. foreach ($this->repositories as $repository) {
  26743. if ($package = $repository->findPackage($name, $constraint)) {
  26744. return $package;
  26745. }
  26746. }
  26747. return null;
  26748. }
  26749. public function findPackages($name, $constraint)
  26750. {
  26751. $packages = array();
  26752. foreach ($this->getRepositories() as $repository) {
  26753. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  26754. }
  26755. return $packages;
  26756. }
  26757. public function addRepository(RepositoryInterface $repository)
  26758. {
  26759. $this->repositories[] = $repository;
  26760. }
  26761. public function prependRepository(RepositoryInterface $repository)
  26762. {
  26763. array_unshift($this->repositories, $repository);
  26764. }
  26765. public function createRepository($type, $config, $name = null)
  26766. {
  26767. if (!isset($this->repositoryClasses[$type])) {
  26768. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  26769. }
  26770. if (isset($config['packagist']) && false === $config['packagist']) {
  26771. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  26772. }
  26773. $class = $this->repositoryClasses[$type];
  26774. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  26775. $filterConfig = $config;
  26776. unset($config['only'], $config['exclude'], $config['canonical']);
  26777. }
  26778. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  26779. if (isset($filterConfig)) {
  26780. $repository = new FilterRepository($repository, $filterConfig);
  26781. }
  26782. return $repository;
  26783. }
  26784. public function setRepositoryClass($type, $class)
  26785. {
  26786. $this->repositoryClasses[$type] = $class;
  26787. }
  26788. public function getRepositories()
  26789. {
  26790. return $this->repositories;
  26791. }
  26792. public function setLocalRepository(InstalledRepositoryInterface $repository)
  26793. {
  26794. $this->localRepository = $repository;
  26795. }
  26796. public function getLocalRepository()
  26797. {
  26798. return $this->localRepository;
  26799. }
  26800. }
  26801. <?php
  26802. namespace Composer\Repository;
  26803. class RepositorySecurityException extends \Exception
  26804. {
  26805. }
  26806. <?php
  26807. namespace Composer\Repository;
  26808. use Composer\DependencyResolver\Pool;
  26809. use Composer\DependencyResolver\PoolBuilder;
  26810. use Composer\DependencyResolver\Request;
  26811. use Composer\EventDispatcher\EventDispatcher;
  26812. use Composer\IO\IOInterface;
  26813. use Composer\IO\NullIO;
  26814. use Composer\Package\BasePackage;
  26815. use Composer\Package\AliasPackage;
  26816. use Composer\Package\CompleteAliasPackage;
  26817. use Composer\Package\CompletePackage;
  26818. use Composer\Semver\Constraint\ConstraintInterface;
  26819. use Composer\Package\Version\StabilityFilter;
  26820. class RepositorySet
  26821. {
  26822. const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  26823. const ALLOW_SHADOWED_REPOSITORIES = 2;
  26824. private $rootAliases;
  26825. private $rootReferences;
  26826. private $repositories = array();
  26827. private $acceptableStabilities;
  26828. private $stabilityFlags;
  26829. private $rootRequires;
  26830. private $locked = false;
  26831. private $allowInstalledRepositories = false;
  26832. public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
  26833. {
  26834. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  26835. $this->rootReferences = $rootReferences;
  26836. $this->acceptableStabilities = array();
  26837. foreach (BasePackage::$stabilities as $stability => $value) {
  26838. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  26839. $this->acceptableStabilities[$stability] = $value;
  26840. }
  26841. }
  26842. $this->stabilityFlags = $stabilityFlags;
  26843. $this->rootRequires = $rootRequires;
  26844. foreach ($rootRequires as $name => $constraint) {
  26845. if (PlatformRepository::isPlatformPackage($name)) {
  26846. unset($this->rootRequires[$name]);
  26847. }
  26848. }
  26849. }
  26850. public function allowInstalledRepositories($allow = true)
  26851. {
  26852. $this->allowInstalledRepositories = $allow;
  26853. }
  26854. public function getRootRequires()
  26855. {
  26856. return $this->rootRequires;
  26857. }
  26858. public function addRepository(RepositoryInterface $repo)
  26859. {
  26860. if ($this->locked) {
  26861. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  26862. }
  26863. if ($repo instanceof CompositeRepository) {
  26864. $repos = $repo->getRepositories();
  26865. } else {
  26866. $repos = array($repo);
  26867. }
  26868. foreach ($repos as $repo) {
  26869. $this->repositories[] = $repo;
  26870. }
  26871. }
  26872. public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
  26873. {
  26874. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  26875. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  26876. $packages = array();
  26877. if ($loadFromAllRepos) {
  26878. foreach ($this->repositories as $repository) {
  26879. $packages[] = $repository->findPackages($name, $constraint) ?: array();
  26880. }
  26881. } else {
  26882. foreach ($this->repositories as $repository) {
  26883. $result = $repository->loadPackages(array($name => $constraint), $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? array() : $this->stabilityFlags);
  26884. $packages[] = $result['packages'];
  26885. foreach ($result['namesFound'] as $nameFound) {
  26886. if ($name === $nameFound) {
  26887. break 2;
  26888. }
  26889. }
  26890. }
  26891. }
  26892. $candidates = $packages ? call_user_func_array('array_merge', $packages) : array();
  26893. if ($ignoreStability || !$loadFromAllRepos) {
  26894. return $candidates;
  26895. }
  26896. $result = array();
  26897. foreach ($candidates as $candidate) {
  26898. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  26899. $result[] = $candidate;
  26900. }
  26901. }
  26902. return $result;
  26903. }
  26904. public function getProviders($packageName)
  26905. {
  26906. $providers = array();
  26907. foreach ($this->repositories as $repository) {
  26908. if ($repoProviders = $repository->getProviders($packageName)) {
  26909. $providers = array_merge($providers, $repoProviders);
  26910. }
  26911. }
  26912. return $providers;
  26913. }
  26914. public function isPackageAcceptable($names, $stability)
  26915. {
  26916. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  26917. }
  26918. public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null)
  26919. {
  26920. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher);
  26921. foreach ($this->repositories as $repo) {
  26922. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  26923. throw new \LogicException('The pool can not accept packages from an installed repository');
  26924. }
  26925. }
  26926. $this->locked = true;
  26927. return $poolBuilder->buildPool($this->repositories, $request);
  26928. }
  26929. public function createPoolWithAllPackages()
  26930. {
  26931. foreach ($this->repositories as $repo) {
  26932. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  26933. throw new \LogicException('The pool can not accept packages from an installed repository');
  26934. }
  26935. }
  26936. $this->locked = true;
  26937. $packages = array();
  26938. foreach ($this->repositories as $repository) {
  26939. foreach ($repository->getPackages() as $package) {
  26940. $packages[] = $package;
  26941. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  26942. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  26943. while ($package instanceof AliasPackage) {
  26944. $package = $package->getAliasOf();
  26945. }
  26946. if ($package instanceof CompletePackage) {
  26947. $aliasPackage = new CompleteAliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  26948. } else {
  26949. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  26950. }
  26951. $aliasPackage->setRootPackageAlias(true);
  26952. $packages[] = $aliasPackage;
  26953. }
  26954. }
  26955. }
  26956. return new Pool($packages);
  26957. }
  26958. public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
  26959. {
  26960. return $this->createPoolForPackages(array($packageName), $lockedRepo);
  26961. }
  26962. public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
  26963. {
  26964. $request = new Request($lockedRepo);
  26965. foreach ($packageNames as $packageName) {
  26966. if (PlatformRepository::isPlatformPackage($packageName)) {
  26967. 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.');
  26968. }
  26969. $request->requireName($packageName);
  26970. }
  26971. return $this->createPool($request, new NullIO());
  26972. }
  26973. private static function getRootAliasesPerPackage(array $aliases)
  26974. {
  26975. $normalizedAliases = array();
  26976. foreach ($aliases as $alias) {
  26977. $normalizedAliases[$alias['package']][$alias['version']] = array(
  26978. 'alias' => $alias['alias'],
  26979. 'alias_normalized' => $alias['alias_normalized'],
  26980. );
  26981. }
  26982. return $normalizedAliases;
  26983. }
  26984. }
  26985. <?php
  26986. namespace Composer\Repository;
  26987. use Composer\Package\RootPackageInterface;
  26988. class RootPackageRepository extends ArrayRepository
  26989. {
  26990. public function __construct(RootPackageInterface $package)
  26991. {
  26992. parent::__construct(array($package));
  26993. }
  26994. public function getRepoName()
  26995. {
  26996. return 'root package repo';
  26997. }
  26998. }
  26999. <?php
  27000. namespace Composer\Repository\Vcs;
  27001. use Composer\Cache;
  27002. use Composer\Downloader\TransportException;
  27003. use Composer\Json\JsonFile;
  27004. use Composer\Util\Bitbucket;
  27005. use Composer\Util\Http\Response;
  27006. abstract class BitbucketDriver extends VcsDriver
  27007. {
  27008. protected $owner;
  27009. protected $repository;
  27010. protected $hasIssues = false;
  27011. protected $rootIdentifier;
  27012. protected $tags;
  27013. protected $branches;
  27014. protected $branchesUrl = '';
  27015. protected $tagsUrl = '';
  27016. protected $homeUrl = '';
  27017. protected $website = '';
  27018. protected $cloneHttpsUrl = '';
  27019. protected $fallbackDriver = null;
  27020. protected $vcsType;
  27021. public function initialize()
  27022. {
  27023. preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)$#i', $this->url, $match);
  27024. $this->owner = $match[1];
  27025. $this->repository = $match[2];
  27026. $this->originUrl = 'bitbucket.org';
  27027. $this->cache = new Cache(
  27028. $this->io,
  27029. implode('/', array(
  27030. $this->config->get('cache-repo-dir'),
  27031. $this->originUrl,
  27032. $this->owner,
  27033. $this->repository,
  27034. ))
  27035. );
  27036. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  27037. }
  27038. public function getUrl()
  27039. {
  27040. if ($this->fallbackDriver) {
  27041. return $this->fallbackDriver->getUrl();
  27042. }
  27043. return $this->cloneHttpsUrl;
  27044. }
  27045. protected function getRepoData()
  27046. {
  27047. $resource = sprintf(
  27048. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  27049. $this->owner,
  27050. $this->repository,
  27051. http_build_query(
  27052. array('fields' => '-project,-owner'),
  27053. '',
  27054. '&'
  27055. )
  27056. );
  27057. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  27058. if ($this->fallbackDriver) {
  27059. return false;
  27060. }
  27061. $this->parseCloneUrls($repoData['links']['clone']);
  27062. $this->hasIssues = !empty($repoData['has_issues']);
  27063. $this->branchesUrl = $repoData['links']['branches']['href'];
  27064. $this->tagsUrl = $repoData['links']['tags']['href'];
  27065. $this->homeUrl = $repoData['links']['html']['href'];
  27066. $this->website = $repoData['website'];
  27067. $this->vcsType = $repoData['scm'];
  27068. return true;
  27069. }
  27070. public function getComposerInformation($identifier)
  27071. {
  27072. if ($this->fallbackDriver) {
  27073. return $this->fallbackDriver->getComposerInformation($identifier);
  27074. }
  27075. if (!isset($this->infoCache[$identifier])) {
  27076. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  27077. $composer = JsonFile::parseJson($res);
  27078. } else {
  27079. $composer = $this->getBaseComposerInformation($identifier);
  27080. if ($this->shouldCache($identifier)) {
  27081. $this->cache->write($identifier, json_encode($composer));
  27082. }
  27083. }
  27084. if ($composer) {
  27085. if (!isset($composer['support']['source'])) {
  27086. $label = array_search(
  27087. $identifier,
  27088. $this->getTags()
  27089. ) ?: array_search(
  27090. $identifier,
  27091. $this->getBranches()
  27092. ) ?: $identifier;
  27093. if (array_key_exists($label, $tags = $this->getTags())) {
  27094. $hash = $tags[$label];
  27095. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  27096. $hash = $branches[$label];
  27097. }
  27098. if (!isset($hash)) {
  27099. $composer['support']['source'] = sprintf(
  27100. 'https://%s/%s/%s/src',
  27101. $this->originUrl,
  27102. $this->owner,
  27103. $this->repository
  27104. );
  27105. } else {
  27106. $composer['support']['source'] = sprintf(
  27107. 'https://%s/%s/%s/src/%s/?at=%s',
  27108. $this->originUrl,
  27109. $this->owner,
  27110. $this->repository,
  27111. $hash,
  27112. $label
  27113. );
  27114. }
  27115. }
  27116. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  27117. $composer['support']['issues'] = sprintf(
  27118. 'https://%s/%s/%s/issues',
  27119. $this->originUrl,
  27120. $this->owner,
  27121. $this->repository
  27122. );
  27123. }
  27124. if (!isset($composer['homepage'])) {
  27125. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  27126. }
  27127. }
  27128. $this->infoCache[$identifier] = $composer;
  27129. }
  27130. return $this->infoCache[$identifier];
  27131. }
  27132. public function getFileContent($file, $identifier)
  27133. {
  27134. if ($this->fallbackDriver) {
  27135. return $this->fallbackDriver->getFileContent($file, $identifier);
  27136. }
  27137. if (strpos($identifier, '/') !== false) {
  27138. $branches = $this->getBranches();
  27139. if (isset($branches[$identifier])) {
  27140. $identifier = $branches[$identifier];
  27141. }
  27142. }
  27143. $resource = sprintf(
  27144. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  27145. $this->owner,
  27146. $this->repository,
  27147. $identifier,
  27148. $file
  27149. );
  27150. return $this->fetchWithOAuthCredentials($resource)->getBody();
  27151. }
  27152. public function getChangeDate($identifier)
  27153. {
  27154. if ($this->fallbackDriver) {
  27155. return $this->fallbackDriver->getChangeDate($identifier);
  27156. }
  27157. if (strpos($identifier, '/') !== false) {
  27158. $branches = $this->getBranches();
  27159. if (isset($branches[$identifier])) {
  27160. $identifier = $branches[$identifier];
  27161. }
  27162. }
  27163. $resource = sprintf(
  27164. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  27165. $this->owner,
  27166. $this->repository,
  27167. $identifier
  27168. );
  27169. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  27170. return new \DateTime($commit['date']);
  27171. }
  27172. public function getSource($identifier)
  27173. {
  27174. if ($this->fallbackDriver) {
  27175. return $this->fallbackDriver->getSource($identifier);
  27176. }
  27177. return array('type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier);
  27178. }
  27179. public function getDist($identifier)
  27180. {
  27181. if ($this->fallbackDriver) {
  27182. return $this->fallbackDriver->getDist($identifier);
  27183. }
  27184. $url = sprintf(
  27185. 'https://bitbucket.org/%s/%s/get/%s.zip',
  27186. $this->owner,
  27187. $this->repository,
  27188. $identifier
  27189. );
  27190. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  27191. }
  27192. public function getTags()
  27193. {
  27194. if ($this->fallbackDriver) {
  27195. return $this->fallbackDriver->getTags();
  27196. }
  27197. if (null === $this->tags) {
  27198. $this->tags = array();
  27199. $resource = sprintf(
  27200. '%s?%s',
  27201. $this->tagsUrl,
  27202. http_build_query(
  27203. array(
  27204. 'pagelen' => 100,
  27205. 'fields' => 'values.name,values.target.hash,next',
  27206. 'sort' => '-target.date',
  27207. ),
  27208. '',
  27209. '&'
  27210. )
  27211. );
  27212. $hasNext = true;
  27213. while ($hasNext) {
  27214. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  27215. foreach ($tagsData['values'] as $data) {
  27216. $this->tags[$data['name']] = $data['target']['hash'];
  27217. }
  27218. if (empty($tagsData['next'])) {
  27219. $hasNext = false;
  27220. } else {
  27221. $resource = $tagsData['next'];
  27222. }
  27223. }
  27224. if ($this->vcsType === 'hg') {
  27225. unset($this->tags['tip']);
  27226. }
  27227. }
  27228. return $this->tags;
  27229. }
  27230. public function getBranches()
  27231. {
  27232. if ($this->fallbackDriver) {
  27233. return $this->fallbackDriver->getBranches();
  27234. }
  27235. if (null === $this->branches) {
  27236. $this->branches = array();
  27237. $resource = sprintf(
  27238. '%s?%s',
  27239. $this->branchesUrl,
  27240. http_build_query(
  27241. array(
  27242. 'pagelen' => 100,
  27243. 'fields' => 'values.name,values.target.hash,values.heads,next',
  27244. 'sort' => '-target.date',
  27245. ),
  27246. '',
  27247. '&'
  27248. )
  27249. );
  27250. $hasNext = true;
  27251. while ($hasNext) {
  27252. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  27253. foreach ($branchData['values'] as $data) {
  27254. if ($this->vcsType === 'hg' && empty($data['heads'])) {
  27255. continue;
  27256. }
  27257. $this->branches[$data['name']] = $data['target']['hash'];
  27258. }
  27259. if (empty($branchData['next'])) {
  27260. $hasNext = false;
  27261. } else {
  27262. $resource = $branchData['next'];
  27263. }
  27264. }
  27265. }
  27266. return $this->branches;
  27267. }
  27268. protected function fetchWithOAuthCredentials($url, $fetchingRepoData = false)
  27269. {
  27270. try {
  27271. return parent::getContents($url);
  27272. } catch (TransportException $e) {
  27273. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  27274. if (403 === $e->getCode() || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  27275. if (!$this->io->hasAuthentication($this->originUrl)
  27276. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  27277. ) {
  27278. return parent::getContents($url);
  27279. }
  27280. if (!$this->io->isInteractive() && $fetchingRepoData) {
  27281. $this->attemptCloneFallback();
  27282. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  27283. }
  27284. }
  27285. throw $e;
  27286. }
  27287. }
  27288. abstract protected function generateSshUrl();
  27289. protected function attemptCloneFallback()
  27290. {
  27291. try {
  27292. $this->setupFallbackDriver($this->generateSshUrl());
  27293. return true;
  27294. } catch (\RuntimeException $e) {
  27295. $this->fallbackDriver = null;
  27296. $this->io->writeError(
  27297. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  27298. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  27299. );
  27300. throw $e;
  27301. }
  27302. }
  27303. abstract protected function setupFallbackDriver($url);
  27304. protected function parseCloneUrls(array $cloneLinks)
  27305. {
  27306. foreach ($cloneLinks as $cloneLink) {
  27307. if ($cloneLink['name'] === 'https') {
  27308. $this->cloneHttpsUrl = preg_replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  27309. }
  27310. }
  27311. }
  27312. protected function getMainBranchData()
  27313. {
  27314. $resource = sprintf(
  27315. 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
  27316. $this->owner,
  27317. $this->repository
  27318. );
  27319. $data = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  27320. if (isset($data['mainbranch'])) {
  27321. return $data['mainbranch'];
  27322. }
  27323. return null;
  27324. }
  27325. }
  27326. <?php
  27327. namespace Composer\Repository\Vcs;
  27328. use Composer\Cache;
  27329. use Composer\Config;
  27330. use Composer\Util\ProcessExecutor;
  27331. use Composer\Util\Filesystem;
  27332. use Composer\IO\IOInterface;
  27333. class FossilDriver extends VcsDriver
  27334. {
  27335. protected $tags;
  27336. protected $branches;
  27337. protected $rootIdentifier = null;
  27338. protected $repoFile = null;
  27339. protected $checkoutDir;
  27340. public function initialize()
  27341. {
  27342. $this->checkFossil();
  27343. $this->config->prohibitUrlByConfig($this->url, $this->io);
  27344. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  27345. $this->checkoutDir = $this->url;
  27346. } else {
  27347. if (!Cache::isUsable((string) $this->config->get('cache-repo-dir')) || !Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  27348. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  27349. }
  27350. $localName = preg_replace('{[^a-z0-9]}i', '-', $this->url);
  27351. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  27352. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  27353. $this->updateLocalRepo();
  27354. }
  27355. $this->getTags();
  27356. $this->getBranches();
  27357. }
  27358. protected function checkFossil()
  27359. {
  27360. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  27361. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  27362. }
  27363. }
  27364. protected function updateLocalRepo()
  27365. {
  27366. $fs = new Filesystem();
  27367. $fs->ensureDirectoryExists($this->checkoutDir);
  27368. if (!is_writable(dirname($this->checkoutDir))) {
  27369. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  27370. }
  27371. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  27372. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  27373. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  27374. }
  27375. } else {
  27376. $fs->removeDirectory($this->checkoutDir);
  27377. $fs->remove($this->repoFile);
  27378. $fs->ensureDirectoryExists($this->checkoutDir);
  27379. if (0 !== $this->process->execute(sprintf('fossil clone -- %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  27380. $output = $this->process->getErrorOutput();
  27381. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  27382. }
  27383. if (0 !== $this->process->execute(sprintf('fossil open --nested -- %s', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  27384. $output = $this->process->getErrorOutput();
  27385. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  27386. }
  27387. }
  27388. }
  27389. public function getRootIdentifier()
  27390. {
  27391. if (null === $this->rootIdentifier) {
  27392. $this->rootIdentifier = 'trunk';
  27393. }
  27394. return $this->rootIdentifier;
  27395. }
  27396. public function getUrl()
  27397. {
  27398. return $this->url;
  27399. }
  27400. public function getSource($identifier)
  27401. {
  27402. return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
  27403. }
  27404. public function getDist($identifier)
  27405. {
  27406. return null;
  27407. }
  27408. public function getFileContent($file, $identifier)
  27409. {
  27410. $command = sprintf('fossil cat -r %s -- %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  27411. $this->process->execute($command, $content, $this->checkoutDir);
  27412. if (!trim($content)) {
  27413. return null;
  27414. }
  27415. return $content;
  27416. }
  27417. public function getChangeDate($identifier)
  27418. {
  27419. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  27420. list(, $date) = explode(' ', trim($output), 3);
  27421. return new \DateTime($date, new \DateTimeZone('UTC'));
  27422. }
  27423. public function getTags()
  27424. {
  27425. if (null === $this->tags) {
  27426. $tags = array();
  27427. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  27428. foreach ($this->process->splitLines($output) as $tag) {
  27429. $tags[$tag] = $tag;
  27430. }
  27431. $this->tags = $tags;
  27432. }
  27433. return $this->tags;
  27434. }
  27435. public function getBranches()
  27436. {
  27437. if (null === $this->branches) {
  27438. $branches = array();
  27439. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  27440. foreach ($this->process->splitLines($output) as $branch) {
  27441. $branch = trim(preg_replace('/^\*/', '', trim($branch)));
  27442. $branches[$branch] = $branch;
  27443. }
  27444. $this->branches = $branches;
  27445. }
  27446. return $this->branches;
  27447. }
  27448. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27449. {
  27450. if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  27451. return true;
  27452. }
  27453. if (preg_match('!/fossil/|\.fossil!', $url)) {
  27454. return true;
  27455. }
  27456. if (Filesystem::isLocalPath($url)) {
  27457. $url = Filesystem::getPlatformPath($url);
  27458. if (!is_dir($url)) {
  27459. return false;
  27460. }
  27461. $process = new ProcessExecutor($io);
  27462. if ($process->execute('fossil info', $output, $url) === 0) {
  27463. return true;
  27464. }
  27465. }
  27466. return false;
  27467. }
  27468. }
  27469. <?php
  27470. namespace Composer\Repository\Vcs;
  27471. use Composer\Config;
  27472. use Composer\IO\IOInterface;
  27473. class GitBitbucketDriver extends BitbucketDriver
  27474. {
  27475. public function getRootIdentifier()
  27476. {
  27477. if ($this->fallbackDriver) {
  27478. return $this->fallbackDriver->getRootIdentifier();
  27479. }
  27480. if (null === $this->rootIdentifier) {
  27481. if (!$this->getRepoData()) {
  27482. if (!$this->fallbackDriver) {
  27483. throw new \LogicException('A fallback driver should be setup if getRepoData returns false');
  27484. }
  27485. return $this->fallbackDriver->getRootIdentifier();
  27486. }
  27487. if ($this->vcsType !== 'git') {
  27488. throw new \RuntimeException(
  27489. $this->url.' does not appear to be a git repository, use '.
  27490. $this->cloneHttpsUrl.' if this is a mercurial bitbucket repository'
  27491. );
  27492. }
  27493. $mainBranchData = $this->getMainBranchData();
  27494. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'master';
  27495. }
  27496. return $this->rootIdentifier;
  27497. }
  27498. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27499. {
  27500. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/(.+?)\.git$#i', $url)) {
  27501. return false;
  27502. }
  27503. if (!extension_loaded('openssl')) {
  27504. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  27505. return false;
  27506. }
  27507. return true;
  27508. }
  27509. protected function setupFallbackDriver($url)
  27510. {
  27511. $this->fallbackDriver = new GitDriver(
  27512. array('url' => $url),
  27513. $this->io,
  27514. $this->config,
  27515. $this->httpDownloader,
  27516. $this->process
  27517. );
  27518. $this->fallbackDriver->initialize();
  27519. }
  27520. protected function generateSshUrl()
  27521. {
  27522. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  27523. }
  27524. }
  27525. <?php
  27526. namespace Composer\Repository\Vcs;
  27527. use Composer\Util\ProcessExecutor;
  27528. use Composer\Util\Filesystem;
  27529. use Composer\Util\Url;
  27530. use Composer\Util\Git as GitUtil;
  27531. use Composer\IO\IOInterface;
  27532. use Composer\Cache;
  27533. use Composer\Config;
  27534. class GitDriver extends VcsDriver
  27535. {
  27536. protected $tags;
  27537. protected $branches;
  27538. protected $rootIdentifier;
  27539. protected $repoDir;
  27540. public function initialize()
  27541. {
  27542. if (Filesystem::isLocalPath($this->url)) {
  27543. $this->url = preg_replace('{[\\/]\.git/?$}', '', $this->url);
  27544. if (!is_dir($this->url)) {
  27545. throw new \RuntimeException('Failed to read package information from '.$this->url.' as the path does not exist');
  27546. }
  27547. $this->repoDir = $this->url;
  27548. $cacheUrl = realpath($this->url);
  27549. } else {
  27550. if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  27551. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  27552. }
  27553. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  27554. GitUtil::cleanEnv();
  27555. $fs = new Filesystem();
  27556. $fs->ensureDirectoryExists(dirname($this->repoDir));
  27557. if (!is_writable(dirname($this->repoDir))) {
  27558. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  27559. }
  27560. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  27561. 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.');
  27562. }
  27563. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  27564. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  27565. if (!is_dir($this->repoDir)) {
  27566. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  27567. }
  27568. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  27569. }
  27570. $cacheUrl = $this->url;
  27571. }
  27572. $this->getTags();
  27573. $this->getBranches();
  27574. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  27575. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  27576. }
  27577. public function getRootIdentifier()
  27578. {
  27579. if (null === $this->rootIdentifier) {
  27580. $this->rootIdentifier = 'master';
  27581. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  27582. $branches = $this->process->splitLines($output);
  27583. if (!in_array('* master', $branches)) {
  27584. foreach ($branches as $branch) {
  27585. if ($branch && preg_match('{^\* +(\S+)}', $branch, $match)) {
  27586. $this->rootIdentifier = $match[1];
  27587. break;
  27588. }
  27589. }
  27590. }
  27591. }
  27592. return $this->rootIdentifier;
  27593. }
  27594. public function getUrl()
  27595. {
  27596. return $this->url;
  27597. }
  27598. public function getSource($identifier)
  27599. {
  27600. return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
  27601. }
  27602. public function getDist($identifier)
  27603. {
  27604. return null;
  27605. }
  27606. public function getFileContent($file, $identifier)
  27607. {
  27608. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  27609. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  27610. if (!trim($content)) {
  27611. return null;
  27612. }
  27613. return $content;
  27614. }
  27615. public function getChangeDate($identifier)
  27616. {
  27617. $this->process->execute(sprintf(
  27618. 'git -c log.showSignature=false log -1 --format=%%at %s',
  27619. ProcessExecutor::escape($identifier)
  27620. ), $output, $this->repoDir);
  27621. return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  27622. }
  27623. public function getTags()
  27624. {
  27625. if (null === $this->tags) {
  27626. $this->tags = array();
  27627. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  27628. foreach ($output = $this->process->splitLines($output) as $tag) {
  27629. if ($tag && preg_match('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  27630. $this->tags[$match[2]] = $match[1];
  27631. }
  27632. }
  27633. }
  27634. return $this->tags;
  27635. }
  27636. public function getBranches()
  27637. {
  27638. if (null === $this->branches) {
  27639. $branches = array();
  27640. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  27641. foreach ($this->process->splitLines($output) as $branch) {
  27642. if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
  27643. if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match)) {
  27644. $branches[$match[1]] = $match[2];
  27645. }
  27646. }
  27647. }
  27648. $this->branches = $branches;
  27649. }
  27650. return $this->branches;
  27651. }
  27652. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27653. {
  27654. if (preg_match('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  27655. return true;
  27656. }
  27657. if (Filesystem::isLocalPath($url)) {
  27658. $url = Filesystem::getPlatformPath($url);
  27659. if (!is_dir($url)) {
  27660. return false;
  27661. }
  27662. $process = new ProcessExecutor($io);
  27663. if ($process->execute('git tag', $output, $url) === 0) {
  27664. return true;
  27665. }
  27666. }
  27667. if (!$deep) {
  27668. return false;
  27669. }
  27670. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  27671. GitUtil::cleanEnv();
  27672. try {
  27673. $gitUtil->runCommand(function ($url) {
  27674. return 'git ls-remote --heads -- ' . ProcessExecutor::escape($url);
  27675. }, $url, sys_get_temp_dir());
  27676. } catch (\RuntimeException $e) {
  27677. return false;
  27678. }
  27679. return true;
  27680. }
  27681. }
  27682. <?php
  27683. namespace Composer\Repository\Vcs;
  27684. use Composer\Config;
  27685. use Composer\Downloader\TransportException;
  27686. use Composer\Json\JsonFile;
  27687. use Composer\Cache;
  27688. use Composer\IO\IOInterface;
  27689. use Composer\Util\GitHub;
  27690. use Composer\Util\Http\Response;
  27691. class GitHubDriver extends VcsDriver
  27692. {
  27693. protected $owner;
  27694. protected $repository;
  27695. protected $tags;
  27696. protected $branches;
  27697. protected $rootIdentifier;
  27698. protected $repoData;
  27699. protected $hasIssues = false;
  27700. protected $isPrivate = false;
  27701. private $isArchived = false;
  27702. private $fundingInfo;
  27703. protected $gitDriver = null;
  27704. public function initialize()
  27705. {
  27706. preg_match('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match);
  27707. $this->owner = $match[3];
  27708. $this->repository = $match[4];
  27709. $this->originUrl = strtolower(!empty($match[1]) ? $match[1] : $match[2]);
  27710. if ($this->originUrl === 'www.github.com') {
  27711. $this->originUrl = 'github.com';
  27712. }
  27713. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  27714. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  27715. if ($this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'])) {
  27716. $this->setupGitDriver($this->url);
  27717. return;
  27718. }
  27719. $this->fetchRootIdentifier();
  27720. }
  27721. public function getRepositoryUrl()
  27722. {
  27723. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  27724. }
  27725. public function getRootIdentifier()
  27726. {
  27727. if ($this->gitDriver) {
  27728. return $this->gitDriver->getRootIdentifier();
  27729. }
  27730. return $this->rootIdentifier;
  27731. }
  27732. public function getUrl()
  27733. {
  27734. if ($this->gitDriver) {
  27735. return $this->gitDriver->getUrl();
  27736. }
  27737. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  27738. }
  27739. protected function getApiUrl()
  27740. {
  27741. if ('github.com' === $this->originUrl) {
  27742. $apiUrl = 'api.github.com';
  27743. } else {
  27744. $apiUrl = $this->originUrl . '/api/v3';
  27745. }
  27746. return 'https://' . $apiUrl;
  27747. }
  27748. public function getSource($identifier)
  27749. {
  27750. if ($this->gitDriver) {
  27751. return $this->gitDriver->getSource($identifier);
  27752. }
  27753. if ($this->isPrivate) {
  27754. $url = $this->generateSshUrl();
  27755. } else {
  27756. $url = $this->getUrl();
  27757. }
  27758. return array('type' => 'git', 'url' => $url, 'reference' => $identifier);
  27759. }
  27760. public function getDist($identifier)
  27761. {
  27762. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  27763. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  27764. }
  27765. public function getComposerInformation($identifier)
  27766. {
  27767. if ($this->gitDriver) {
  27768. return $this->gitDriver->getComposerInformation($identifier);
  27769. }
  27770. if (!isset($this->infoCache[$identifier])) {
  27771. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  27772. $composer = JsonFile::parseJson($res);
  27773. } else {
  27774. $composer = $this->getBaseComposerInformation($identifier);
  27775. if ($this->shouldCache($identifier)) {
  27776. $this->cache->write($identifier, json_encode($composer));
  27777. }
  27778. }
  27779. if ($composer) {
  27780. if (!isset($composer['support']['source'])) {
  27781. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  27782. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  27783. }
  27784. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  27785. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  27786. }
  27787. if (!isset($composer['abandoned']) && $this->isArchived) {
  27788. $composer['abandoned'] = true;
  27789. }
  27790. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  27791. $composer['funding'] = $funding;
  27792. }
  27793. }
  27794. $this->infoCache[$identifier] = $composer;
  27795. }
  27796. return $this->infoCache[$identifier];
  27797. }
  27798. private function getFundingInfo()
  27799. {
  27800. if (null !== $this->fundingInfo) {
  27801. return $this->fundingInfo;
  27802. }
  27803. if ($this->originUrl !== 'github.com') {
  27804. return $this->fundingInfo = false;
  27805. }
  27806. foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) {
  27807. try {
  27808. $response = $this->httpDownloader->get($file, array(
  27809. 'retry-auth-failure' => false,
  27810. ))->decodeJson();
  27811. } catch (TransportException $e) {
  27812. continue;
  27813. }
  27814. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  27815. continue;
  27816. }
  27817. break;
  27818. }
  27819. if (empty($funding)) {
  27820. return $this->fundingInfo = false;
  27821. }
  27822. $result = array();
  27823. $key = null;
  27824. foreach (preg_split('{\r?\n}', $funding) as $line) {
  27825. $line = trim($line);
  27826. if (preg_match('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  27827. if (preg_match('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
  27828. foreach (array_map('trim', preg_split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  27829. $result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
  27830. }
  27831. } elseif (preg_match('{^([^#].*?)(\s+#.*)?$}', $match[2], $match2)) {
  27832. $result[] = array('type' => $match[1], 'url' => trim($match2[1], '"\' '));
  27833. }
  27834. $key = null;
  27835. } elseif (preg_match('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  27836. $key = $match[1];
  27837. } elseif ($key && preg_match('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) {
  27838. $result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
  27839. }
  27840. }
  27841. foreach ($result as $key => $item) {
  27842. switch ($item['type']) {
  27843. case 'tidelift':
  27844. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  27845. break;
  27846. case 'github':
  27847. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  27848. break;
  27849. case 'patreon':
  27850. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  27851. break;
  27852. case 'otechie':
  27853. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  27854. break;
  27855. case 'open_collective':
  27856. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  27857. break;
  27858. case 'liberapay':
  27859. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  27860. break;
  27861. case 'ko_fi':
  27862. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  27863. break;
  27864. case 'issuehunt':
  27865. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  27866. break;
  27867. case 'community_bridge':
  27868. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  27869. break;
  27870. }
  27871. }
  27872. return $this->fundingInfo = $result;
  27873. }
  27874. public function getFileContent($file, $identifier)
  27875. {
  27876. if ($this->gitDriver) {
  27877. return $this->gitDriver->getFileContent($file, $identifier);
  27878. }
  27879. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  27880. $resource = $this->getContents($resource)->decodeJson();
  27881. if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
  27882. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  27883. }
  27884. return $content;
  27885. }
  27886. public function getChangeDate($identifier)
  27887. {
  27888. if ($this->gitDriver) {
  27889. return $this->gitDriver->getChangeDate($identifier);
  27890. }
  27891. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  27892. $commit = $this->getContents($resource)->decodeJson();
  27893. return new \DateTime($commit['commit']['committer']['date']);
  27894. }
  27895. public function getTags()
  27896. {
  27897. if ($this->gitDriver) {
  27898. return $this->gitDriver->getTags();
  27899. }
  27900. if (null === $this->tags) {
  27901. $this->tags = array();
  27902. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  27903. do {
  27904. $response = $this->getContents($resource);
  27905. $tagsData = $response->decodeJson();
  27906. foreach ($tagsData as $tag) {
  27907. $this->tags[$tag['name']] = $tag['commit']['sha'];
  27908. }
  27909. $resource = $this->getNextPage($response);
  27910. } while ($resource);
  27911. }
  27912. return $this->tags;
  27913. }
  27914. public function getBranches()
  27915. {
  27916. if ($this->gitDriver) {
  27917. return $this->gitDriver->getBranches();
  27918. }
  27919. if (null === $this->branches) {
  27920. $this->branches = array();
  27921. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  27922. do {
  27923. $response = $this->getContents($resource);
  27924. $branchData = $response->decodeJson();
  27925. foreach ($branchData as $branch) {
  27926. $name = substr($branch['ref'], 11);
  27927. if ($name !== 'gh-pages') {
  27928. $this->branches[$name] = $branch['object']['sha'];
  27929. }
  27930. }
  27931. $resource = $this->getNextPage($response);
  27932. } while ($resource);
  27933. }
  27934. return $this->branches;
  27935. }
  27936. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27937. {
  27938. if (!preg_match('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
  27939. return false;
  27940. }
  27941. $originUrl = !empty($matches[2]) ? $matches[2] : $matches[3];
  27942. if (!in_array(strtolower(preg_replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  27943. return false;
  27944. }
  27945. if (!extension_loaded('openssl')) {
  27946. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  27947. return false;
  27948. }
  27949. return true;
  27950. }
  27951. public function getRepoData()
  27952. {
  27953. $this->fetchRootIdentifier();
  27954. return $this->repoData;
  27955. }
  27956. protected function generateSshUrl()
  27957. {
  27958. if (false !== strpos($this->originUrl, ':')) {
  27959. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  27960. }
  27961. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  27962. }
  27963. protected function getContents($url, $fetchingRepoData = false)
  27964. {
  27965. try {
  27966. return parent::getContents($url);
  27967. } catch (TransportException $e) {
  27968. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  27969. switch ($e->getCode()) {
  27970. case 401:
  27971. case 404:
  27972. if (!$fetchingRepoData) {
  27973. throw $e;
  27974. }
  27975. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  27976. return parent::getContents($url);
  27977. }
  27978. if (!$this->io->isInteractive()) {
  27979. $this->attemptCloneFallback();
  27980. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  27981. }
  27982. $scopesIssued = array();
  27983. $scopesNeeded = array();
  27984. if ($headers = $e->getHeaders()) {
  27985. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  27986. $scopesIssued = explode(' ', $scopes);
  27987. }
  27988. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  27989. $scopesNeeded = explode(' ', $scopes);
  27990. }
  27991. }
  27992. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  27993. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  27994. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  27995. }
  27996. return parent::getContents($url);
  27997. case 403:
  27998. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  27999. return parent::getContents($url);
  28000. }
  28001. if (!$this->io->isInteractive() && $fetchingRepoData) {
  28002. $this->attemptCloneFallback();
  28003. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  28004. }
  28005. $rateLimited = $gitHubUtil->isRateLimited((array) $e->getHeaders());
  28006. if (!$this->io->hasAuthentication($this->originUrl)) {
  28007. if (!$this->io->isInteractive()) {
  28008. $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>');
  28009. throw $e;
  28010. }
  28011. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  28012. return parent::getContents($url);
  28013. }
  28014. if ($rateLimited) {
  28015. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  28016. $this->io->writeError(sprintf(
  28017. '<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>',
  28018. $rateLimit['limit'],
  28019. $rateLimit['reset']
  28020. ));
  28021. }
  28022. throw $e;
  28023. default:
  28024. throw $e;
  28025. }
  28026. }
  28027. }
  28028. protected function fetchRootIdentifier()
  28029. {
  28030. if ($this->repoData) {
  28031. return;
  28032. }
  28033. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  28034. try {
  28035. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  28036. } catch (TransportException $e) {
  28037. if ($e->getCode() === 499) {
  28038. $this->attemptCloneFallback();
  28039. } else {
  28040. throw $e;
  28041. }
  28042. }
  28043. if (null === $this->repoData && null !== $this->gitDriver) {
  28044. return;
  28045. }
  28046. $this->owner = $this->repoData['owner']['login'];
  28047. $this->repository = $this->repoData['name'];
  28048. $this->isPrivate = !empty($this->repoData['private']);
  28049. if (isset($this->repoData['default_branch'])) {
  28050. $this->rootIdentifier = $this->repoData['default_branch'];
  28051. } elseif (isset($this->repoData['master_branch'])) {
  28052. $this->rootIdentifier = $this->repoData['master_branch'];
  28053. } else {
  28054. $this->rootIdentifier = 'master';
  28055. }
  28056. $this->hasIssues = !empty($this->repoData['has_issues']);
  28057. $this->isArchived = !empty($this->repoData['archived']);
  28058. }
  28059. protected function attemptCloneFallback()
  28060. {
  28061. $this->isPrivate = true;
  28062. try {
  28063. $this->setupGitDriver($this->generateSshUrl());
  28064. return true;
  28065. } catch (\RuntimeException $e) {
  28066. $this->gitDriver = null;
  28067. $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>');
  28068. throw $e;
  28069. }
  28070. }
  28071. protected function setupGitDriver($url)
  28072. {
  28073. $this->gitDriver = new GitDriver(
  28074. array('url' => $url),
  28075. $this->io,
  28076. $this->config,
  28077. $this->httpDownloader,
  28078. $this->process
  28079. );
  28080. $this->gitDriver->initialize();
  28081. }
  28082. protected function getNextPage(Response $response)
  28083. {
  28084. $header = $response->getHeader('link');
  28085. if (!$header) {
  28086. return null;
  28087. }
  28088. $links = explode(',', $header);
  28089. foreach ($links as $link) {
  28090. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  28091. return $match[1];
  28092. }
  28093. }
  28094. return null;
  28095. }
  28096. }
  28097. <?php
  28098. namespace Composer\Repository\Vcs;
  28099. use Composer\Config;
  28100. use Composer\Cache;
  28101. use Composer\IO\IOInterface;
  28102. use Composer\Json\JsonFile;
  28103. use Composer\Downloader\TransportException;
  28104. use Composer\Util\HttpDownloader;
  28105. use Composer\Util\GitLab;
  28106. use Composer\Util\Http\Response;
  28107. class GitLabDriver extends VcsDriver
  28108. {
  28109. private $scheme;
  28110. private $namespace;
  28111. private $repository;
  28112. private $project;
  28113. private $commits = array();
  28114. private $tags;
  28115. private $branches;
  28116. protected $gitDriver = null;
  28117. protected $protocol;
  28118. private $isPrivate = true;
  28119. private $hasNonstandardOrigin = false;
  28120. const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  28121. public function initialize()
  28122. {
  28123. if (!preg_match(self::URL_REGEX, $this->url, $match)) {
  28124. throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
  28125. }
  28126. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  28127. $configuredDomains = $this->config->get('gitlab-domains');
  28128. $urlParts = explode('/', $match['parts']);
  28129. $this->scheme = !empty($match['scheme'])
  28130. ? $match['scheme']
  28131. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  28132. ;
  28133. $this->originUrl = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  28134. if ($protocol = $this->config->get('gitlab-protocol')) {
  28135. if (!in_array($protocol, array('git', 'http', 'https'))) {
  28136. throw new \RuntimeException('gitlab-protocol must be one of git, http.');
  28137. }
  28138. $this->protocol = $protocol === 'git' ? 'ssh' : 'http';
  28139. }
  28140. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  28141. $this->hasNonstandardOrigin = true;
  28142. }
  28143. $this->namespace = implode('/', $urlParts);
  28144. $this->repository = preg_replace('#(\.git)$#', '', $match['repo']);
  28145. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  28146. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  28147. $this->fetchProject();
  28148. }
  28149. public function setHttpDownloader(HttpDownloader $httpDownloader)
  28150. {
  28151. $this->httpDownloader = $httpDownloader;
  28152. }
  28153. public function getComposerInformation($identifier)
  28154. {
  28155. if ($this->gitDriver) {
  28156. return $this->gitDriver->getComposerInformation($identifier);
  28157. }
  28158. if (!isset($this->infoCache[$identifier])) {
  28159. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  28160. $composer = JsonFile::parseJson($res);
  28161. } else {
  28162. $composer = $this->getBaseComposerInformation($identifier);
  28163. if ($this->shouldCache($identifier)) {
  28164. $this->cache->write($identifier, json_encode($composer));
  28165. }
  28166. }
  28167. if ($composer) {
  28168. if (!isset($composer['support']['issues']) && isset($this->project['_links']['issues'])) {
  28169. $composer['support']['issues'] = $this->project['_links']['issues'];
  28170. }
  28171. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  28172. $composer['abandoned'] = true;
  28173. }
  28174. }
  28175. $this->infoCache[$identifier] = $composer;
  28176. }
  28177. return $this->infoCache[$identifier];
  28178. }
  28179. public function getFileContent($file, $identifier)
  28180. {
  28181. if ($this->gitDriver) {
  28182. return $this->gitDriver->getFileContent($file, $identifier);
  28183. }
  28184. if (!preg_match('{[a-f0-9]{40}}i', $identifier)) {
  28185. $branches = $this->getBranches();
  28186. if (isset($branches[$identifier])) {
  28187. $identifier = $branches[$identifier];
  28188. }
  28189. }
  28190. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  28191. try {
  28192. $content = $this->getContents($resource)->getBody();
  28193. } catch (TransportException $e) {
  28194. if ($e->getCode() !== 404) {
  28195. throw $e;
  28196. }
  28197. return null;
  28198. }
  28199. return $content;
  28200. }
  28201. public function getChangeDate($identifier)
  28202. {
  28203. if ($this->gitDriver) {
  28204. return $this->gitDriver->getChangeDate($identifier);
  28205. }
  28206. if (isset($this->commits[$identifier])) {
  28207. return new \DateTime($this->commits[$identifier]['committed_date']);
  28208. }
  28209. return new \DateTime();
  28210. }
  28211. public function getRepositoryUrl()
  28212. {
  28213. if ($this->protocol) {
  28214. return $this->project["{$this->protocol}_url_to_repo"];
  28215. }
  28216. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  28217. }
  28218. public function getUrl()
  28219. {
  28220. if ($this->gitDriver) {
  28221. return $this->gitDriver->getUrl();
  28222. }
  28223. return $this->project['web_url'];
  28224. }
  28225. public function getDist($identifier)
  28226. {
  28227. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  28228. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  28229. }
  28230. public function getSource($identifier)
  28231. {
  28232. if ($this->gitDriver) {
  28233. return $this->gitDriver->getSource($identifier);
  28234. }
  28235. return array('type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier);
  28236. }
  28237. public function getRootIdentifier()
  28238. {
  28239. if ($this->gitDriver) {
  28240. return $this->gitDriver->getRootIdentifier();
  28241. }
  28242. return $this->project['default_branch'];
  28243. }
  28244. public function getBranches()
  28245. {
  28246. if ($this->gitDriver) {
  28247. return $this->gitDriver->getBranches();
  28248. }
  28249. if (!$this->branches) {
  28250. $this->branches = $this->getReferences('branches');
  28251. }
  28252. return $this->branches;
  28253. }
  28254. public function getTags()
  28255. {
  28256. if ($this->gitDriver) {
  28257. return $this->gitDriver->getTags();
  28258. }
  28259. if (!$this->tags) {
  28260. $this->tags = $this->getReferences('tags');
  28261. }
  28262. return $this->tags;
  28263. }
  28264. public function getApiUrl()
  28265. {
  28266. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  28267. }
  28268. private function urlEncodeAll($string)
  28269. {
  28270. $encoded = '';
  28271. for ($i = 0; isset($string[$i]); $i++) {
  28272. $character = $string[$i];
  28273. if (!ctype_alnum($character) && !in_array($character, array('-', '_'), true)) {
  28274. $character = '%' . sprintf('%02X', ord($character));
  28275. }
  28276. $encoded .= $character;
  28277. }
  28278. return $encoded;
  28279. }
  28280. protected function getReferences($type)
  28281. {
  28282. $perPage = 100;
  28283. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  28284. $references = array();
  28285. do {
  28286. $response = $this->getContents($resource);
  28287. $data = $response->decodeJson();
  28288. foreach ($data as $datum) {
  28289. $references[$datum['name']] = $datum['commit']['id'];
  28290. $this->commits[$datum['commit']['id']] = $datum['commit'];
  28291. }
  28292. if (count($data) >= $perPage) {
  28293. $resource = $this->getNextPage($response);
  28294. } else {
  28295. $resource = false;
  28296. }
  28297. } while ($resource);
  28298. return $references;
  28299. }
  28300. protected function fetchProject()
  28301. {
  28302. $resource = $this->getApiUrl();
  28303. $this->project = $this->getContents($resource, true)->decodeJson();
  28304. if (isset($this->project['visibility'])) {
  28305. $this->isPrivate = $this->project['visibility'] !== 'public';
  28306. } else {
  28307. $this->isPrivate = false;
  28308. }
  28309. }
  28310. protected function attemptCloneFallback()
  28311. {
  28312. if ($this->isPrivate === false) {
  28313. $url = $this->generatePublicUrl();
  28314. } else {
  28315. $url = $this->generateSshUrl();
  28316. }
  28317. try {
  28318. $this->setupGitDriver($url);
  28319. return true;
  28320. } catch (\RuntimeException $e) {
  28321. $this->gitDriver = null;
  28322. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  28323. throw $e;
  28324. }
  28325. }
  28326. protected function generateSshUrl()
  28327. {
  28328. if ($this->hasNonstandardOrigin) {
  28329. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  28330. }
  28331. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  28332. }
  28333. protected function generatePublicUrl()
  28334. {
  28335. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  28336. }
  28337. protected function setupGitDriver($url)
  28338. {
  28339. $this->gitDriver = new GitDriver(
  28340. array('url' => $url),
  28341. $this->io,
  28342. $this->config,
  28343. $this->httpDownloader,
  28344. $this->process
  28345. );
  28346. $this->gitDriver->initialize();
  28347. }
  28348. protected function getContents($url, $fetchingRepoData = false)
  28349. {
  28350. try {
  28351. $response = parent::getContents($url);
  28352. if ($fetchingRepoData) {
  28353. $json = $response->decodeJson();
  28354. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  28355. $this->isPrivate = $json['visibility'] !== 'public';
  28356. $moreThanGuestAccess = false;
  28357. foreach ($json['permissions'] as $permission) {
  28358. if ($permission && $permission['access_level'] > 10) {
  28359. $moreThanGuestAccess = true;
  28360. }
  28361. }
  28362. if (!$moreThanGuestAccess) {
  28363. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  28364. $this->attemptCloneFallback();
  28365. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  28366. }
  28367. }
  28368. if (!isset($json['default_branch'])) {
  28369. if (!empty($json['id'])) {
  28370. $this->isPrivate = false;
  28371. }
  28372. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  28373. }
  28374. }
  28375. return $response;
  28376. } catch (TransportException $e) {
  28377. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  28378. switch ($e->getCode()) {
  28379. case 401:
  28380. case 404:
  28381. if (!$fetchingRepoData) {
  28382. throw $e;
  28383. }
  28384. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  28385. return parent::getContents($url);
  28386. }
  28387. if (!$this->io->isInteractive()) {
  28388. $this->attemptCloneFallback();
  28389. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  28390. }
  28391. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  28392. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  28393. return parent::getContents($url);
  28394. case 403:
  28395. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  28396. return parent::getContents($url);
  28397. }
  28398. if (!$this->io->isInteractive() && $fetchingRepoData) {
  28399. $this->attemptCloneFallback();
  28400. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  28401. }
  28402. throw $e;
  28403. default:
  28404. throw $e;
  28405. }
  28406. }
  28407. }
  28408. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  28409. {
  28410. if (!preg_match(self::URL_REGEX, $url, $match)) {
  28411. return false;
  28412. }
  28413. $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
  28414. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  28415. $urlParts = explode('/', $match['parts']);
  28416. if (false === self::determineOrigin((array) $config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  28417. return false;
  28418. }
  28419. if ('https' === $scheme && !extension_loaded('openssl')) {
  28420. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  28421. return false;
  28422. }
  28423. return true;
  28424. }
  28425. protected function getNextPage(Response $response)
  28426. {
  28427. $header = $response->getHeader('link');
  28428. $links = explode(',', $header);
  28429. foreach ($links as $link) {
  28430. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  28431. return $match[1];
  28432. }
  28433. }
  28434. return null;
  28435. }
  28436. private static function determineOrigin(array $configuredDomains, $guessedDomain, array &$urlParts, $portNumber)
  28437. {
  28438. $guessedDomain = strtolower($guessedDomain);
  28439. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  28440. if ($portNumber) {
  28441. return $guessedDomain.':'.$portNumber;
  28442. }
  28443. return $guessedDomain;
  28444. }
  28445. if ($portNumber) {
  28446. $guessedDomain .= ':'.$portNumber;
  28447. }
  28448. while (null !== ($part = array_shift($urlParts))) {
  28449. $guessedDomain .= '/' . $part;
  28450. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array(preg_replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  28451. return $guessedDomain;
  28452. }
  28453. }
  28454. return false;
  28455. }
  28456. }
  28457. <?php
  28458. namespace Composer\Repository\Vcs;
  28459. use Composer\Config;
  28460. use Composer\IO\IOInterface;
  28461. class HgBitbucketDriver extends BitbucketDriver
  28462. {
  28463. public function getRootIdentifier()
  28464. {
  28465. if ($this->fallbackDriver) {
  28466. return $this->fallbackDriver->getRootIdentifier();
  28467. }
  28468. if (null === $this->rootIdentifier) {
  28469. if (!$this->getRepoData()) {
  28470. if (!$this->fallbackDriver) {
  28471. throw new \LogicException('A fallback driver should be setup if getRepoData returns false');
  28472. }
  28473. return $this->fallbackDriver->getRootIdentifier();
  28474. }
  28475. if ($this->vcsType !== 'hg') {
  28476. throw new \RuntimeException(
  28477. $this->url.' does not appear to be a mercurial repository, use '.
  28478. $this->cloneHttpsUrl.' if this is a git bitbucket repository'
  28479. );
  28480. }
  28481. $mainBranchData = $this->getMainBranchData();
  28482. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'default';
  28483. }
  28484. return $this->rootIdentifier;
  28485. }
  28486. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  28487. {
  28488. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#i', $url)) {
  28489. return false;
  28490. }
  28491. if (!extension_loaded('openssl')) {
  28492. $io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  28493. return false;
  28494. }
  28495. return true;
  28496. }
  28497. protected function setupFallbackDriver($url)
  28498. {
  28499. $this->fallbackDriver = new HgDriver(
  28500. array('url' => $url),
  28501. $this->io,
  28502. $this->config,
  28503. $this->httpDownloader,
  28504. $this->process
  28505. );
  28506. $this->fallbackDriver->initialize();
  28507. }
  28508. protected function generateSshUrl()
  28509. {
  28510. return 'ssh://hg@' . $this->originUrl . '/' . $this->owner.'/'.$this->repository;
  28511. }
  28512. }
  28513. <?php
  28514. namespace Composer\Repository\Vcs;
  28515. use Composer\Config;
  28516. use Composer\Cache;
  28517. use Composer\Util\Hg as HgUtils;
  28518. use Composer\Util\ProcessExecutor;
  28519. use Composer\Util\Filesystem;
  28520. use Composer\IO\IOInterface;
  28521. class HgDriver extends VcsDriver
  28522. {
  28523. protected $tags;
  28524. protected $branches;
  28525. protected $rootIdentifier;
  28526. protected $repoDir;
  28527. public function initialize()
  28528. {
  28529. if (Filesystem::isLocalPath($this->url)) {
  28530. $this->repoDir = $this->url;
  28531. } else {
  28532. if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  28533. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  28534. }
  28535. $cacheDir = $this->config->get('cache-vcs-dir');
  28536. $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  28537. $fs = new Filesystem();
  28538. $fs->ensureDirectoryExists($cacheDir);
  28539. if (!is_writable(dirname($this->repoDir))) {
  28540. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  28541. }
  28542. $this->config->prohibitUrlByConfig($this->url, $this->io);
  28543. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  28544. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  28545. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  28546. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  28547. }
  28548. } else {
  28549. $fs->removeDirectory($this->repoDir);
  28550. $repoDir = $this->repoDir;
  28551. $command = function ($url) use ($repoDir) {
  28552. return sprintf('hg clone --noupdate -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($repoDir));
  28553. };
  28554. $hgUtils->runCommand($command, $this->url, null);
  28555. }
  28556. }
  28557. $this->getTags();
  28558. $this->getBranches();
  28559. }
  28560. public function getRootIdentifier()
  28561. {
  28562. if (null === $this->rootIdentifier) {
  28563. $this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
  28564. $output = $this->process->splitLines($output);
  28565. $this->rootIdentifier = $output[0];
  28566. }
  28567. return $this->rootIdentifier;
  28568. }
  28569. public function getUrl()
  28570. {
  28571. return $this->url;
  28572. }
  28573. public function getSource($identifier)
  28574. {
  28575. return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
  28576. }
  28577. public function getDist($identifier)
  28578. {
  28579. return null;
  28580. }
  28581. public function getFileContent($file, $identifier)
  28582. {
  28583. $resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  28584. $this->process->execute($resource, $content, $this->repoDir);
  28585. if (!trim($content)) {
  28586. return null;
  28587. }
  28588. return $content;
  28589. }
  28590. public function getChangeDate($identifier)
  28591. {
  28592. $this->process->execute(
  28593. sprintf(
  28594. 'hg log --template "{date|rfc3339date}" -r %s',
  28595. ProcessExecutor::escape($identifier)
  28596. ),
  28597. $output,
  28598. $this->repoDir
  28599. );
  28600. return new \DateTime(trim($output), new \DateTimeZone('UTC'));
  28601. }
  28602. public function getTags()
  28603. {
  28604. if (null === $this->tags) {
  28605. $tags = array();
  28606. $this->process->execute('hg tags', $output, $this->repoDir);
  28607. foreach ($this->process->splitLines($output) as $tag) {
  28608. if ($tag && preg_match('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  28609. $tags[$match[1]] = $match[2];
  28610. }
  28611. }
  28612. unset($tags['tip']);
  28613. $this->tags = $tags;
  28614. }
  28615. return $this->tags;
  28616. }
  28617. public function getBranches()
  28618. {
  28619. if (null === $this->branches) {
  28620. $branches = array();
  28621. $bookmarks = array();
  28622. $this->process->execute('hg branches', $output, $this->repoDir);
  28623. foreach ($this->process->splitLines($output) as $branch) {
  28624. if ($branch && preg_match('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match)) {
  28625. $branches[$match[1]] = $match[2];
  28626. }
  28627. }
  28628. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  28629. foreach ($this->process->splitLines($output) as $branch) {
  28630. if ($branch && preg_match('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
  28631. $bookmarks[$match[1]] = $match[2];
  28632. }
  28633. }
  28634. $this->branches = array_merge($bookmarks, $branches);
  28635. }
  28636. return $this->branches;
  28637. }
  28638. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  28639. {
  28640. if (preg_match('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  28641. return true;
  28642. }
  28643. if (Filesystem::isLocalPath($url)) {
  28644. $url = Filesystem::getPlatformPath($url);
  28645. if (!is_dir($url)) {
  28646. return false;
  28647. }
  28648. $process = new ProcessExecutor($io);
  28649. if ($process->execute('hg summary', $output, $url) === 0) {
  28650. return true;
  28651. }
  28652. }
  28653. if (!$deep) {
  28654. return false;
  28655. }
  28656. $process = new ProcessExecutor($io);
  28657. $exit = $process->execute(sprintf('hg identify -- %s', ProcessExecutor::escape($url)), $ignored);
  28658. return $exit === 0;
  28659. }
  28660. }
  28661. <?php
  28662. namespace Composer\Repository\Vcs;
  28663. use Composer\Config;
  28664. use Composer\Cache;
  28665. use Composer\IO\IOInterface;
  28666. use Composer\Util\ProcessExecutor;
  28667. use Composer\Util\Perforce;
  28668. class PerforceDriver extends VcsDriver
  28669. {
  28670. protected $depot;
  28671. protected $branch;
  28672. protected $perforce = null;
  28673. public function initialize()
  28674. {
  28675. $this->depot = $this->repoConfig['depot'];
  28676. $this->branch = '';
  28677. if (!empty($this->repoConfig['branch'])) {
  28678. $this->branch = $this->repoConfig['branch'];
  28679. }
  28680. $this->initPerforce($this->repoConfig);
  28681. $this->perforce->p4Login();
  28682. $this->perforce->checkStream();
  28683. $this->perforce->writeP4ClientSpec();
  28684. $this->perforce->connectClient();
  28685. }
  28686. private function initPerforce($repoConfig)
  28687. {
  28688. if (!empty($this->perforce)) {
  28689. return;
  28690. }
  28691. if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  28692. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  28693. }
  28694. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  28695. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  28696. }
  28697. public function getFileContent($file, $identifier)
  28698. {
  28699. return $this->perforce->getFileContent($file, $identifier);
  28700. }
  28701. public function getChangeDate($identifier)
  28702. {
  28703. return null;
  28704. }
  28705. public function getRootIdentifier()
  28706. {
  28707. return $this->branch;
  28708. }
  28709. public function getBranches()
  28710. {
  28711. return $this->perforce->getBranches();
  28712. }
  28713. public function getTags()
  28714. {
  28715. return $this->perforce->getTags();
  28716. }
  28717. public function getDist($identifier)
  28718. {
  28719. return null;
  28720. }
  28721. public function getSource($identifier)
  28722. {
  28723. return array(
  28724. 'type' => 'perforce',
  28725. 'url' => $this->repoConfig['url'],
  28726. 'reference' => $identifier,
  28727. 'p4user' => $this->perforce->getUser(),
  28728. );
  28729. }
  28730. public function getUrl()
  28731. {
  28732. return $this->url;
  28733. }
  28734. public function hasComposerFile($identifier)
  28735. {
  28736. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  28737. return !empty($composerInfo);
  28738. }
  28739. public function getContents($url)
  28740. {
  28741. throw new \BadMethodCallException('Not implemented/used in PerforceDriver');
  28742. }
  28743. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  28744. {
  28745. if ($deep || preg_match('#\b(perforce|p4)\b#i', $url)) {
  28746. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  28747. }
  28748. return false;
  28749. }
  28750. public function cleanup()
  28751. {
  28752. $this->perforce->cleanupClientSpec();
  28753. $this->perforce = null;
  28754. }
  28755. public function getDepot()
  28756. {
  28757. return $this->depot;
  28758. }
  28759. public function getBranch()
  28760. {
  28761. return $this->branch;
  28762. }
  28763. }
  28764. <?php
  28765. namespace Composer\Repository\Vcs;
  28766. use Composer\Cache;
  28767. use Composer\Config;
  28768. use Composer\Json\JsonFile;
  28769. use Composer\Util\ProcessExecutor;
  28770. use Composer\Util\Filesystem;
  28771. use Composer\Util\Url;
  28772. use Composer\Util\Svn as SvnUtil;
  28773. use Composer\IO\IOInterface;
  28774. use Composer\Downloader\TransportException;
  28775. class SvnDriver extends VcsDriver
  28776. {
  28777. protected $baseUrl;
  28778. protected $tags;
  28779. protected $branches;
  28780. protected $rootIdentifier;
  28781. protected $trunkPath = 'trunk';
  28782. protected $branchesPath = 'branches';
  28783. protected $tagsPath = 'tags';
  28784. protected $packagePath = '';
  28785. protected $cacheCredentials = true;
  28786. private $util;
  28787. public function initialize()
  28788. {
  28789. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  28790. SvnUtil::cleanEnv();
  28791. if (isset($this->repoConfig['trunk-path'])) {
  28792. $this->trunkPath = $this->repoConfig['trunk-path'];
  28793. }
  28794. if (isset($this->repoConfig['branches-path'])) {
  28795. $this->branchesPath = $this->repoConfig['branches-path'];
  28796. }
  28797. if (isset($this->repoConfig['tags-path'])) {
  28798. $this->tagsPath = $this->repoConfig['tags-path'];
  28799. }
  28800. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  28801. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  28802. }
  28803. if (isset($this->repoConfig['package-path'])) {
  28804. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  28805. }
  28806. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  28807. $this->baseUrl = substr($this->url, 0, $pos);
  28808. }
  28809. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  28810. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  28811. $this->getBranches();
  28812. $this->getTags();
  28813. }
  28814. public function getRootIdentifier()
  28815. {
  28816. return $this->rootIdentifier ?: $this->trunkPath;
  28817. }
  28818. public function getUrl()
  28819. {
  28820. return $this->url;
  28821. }
  28822. public function getSource($identifier)
  28823. {
  28824. return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
  28825. }
  28826. public function getDist($identifier)
  28827. {
  28828. return null;
  28829. }
  28830. protected function shouldCache($identifier)
  28831. {
  28832. return $this->cache && preg_match('{@\d+$}', $identifier);
  28833. }
  28834. public function getComposerInformation($identifier)
  28835. {
  28836. if (!isset($this->infoCache[$identifier])) {
  28837. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  28838. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  28839. }
  28840. try {
  28841. $composer = $this->getBaseComposerInformation($identifier);
  28842. } catch (TransportException $e) {
  28843. $message = $e->getMessage();
  28844. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  28845. throw $e;
  28846. }
  28847. $composer = '';
  28848. }
  28849. if ($this->shouldCache($identifier)) {
  28850. $this->cache->write($identifier.'.json', json_encode($composer));
  28851. }
  28852. $this->infoCache[$identifier] = $composer;
  28853. }
  28854. return $this->infoCache[$identifier];
  28855. }
  28856. public function getFileContent($file, $identifier)
  28857. {
  28858. $identifier = '/' . trim($identifier, '/') . '/';
  28859. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  28860. if (!empty($match[2])) {
  28861. $path = $match[1];
  28862. $rev = $match[2];
  28863. } else {
  28864. $path = $identifier;
  28865. $rev = '';
  28866. }
  28867. try {
  28868. $resource = $path.$file;
  28869. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  28870. if (!trim($output)) {
  28871. return null;
  28872. }
  28873. } catch (\RuntimeException $e) {
  28874. throw new TransportException($e->getMessage());
  28875. }
  28876. return $output;
  28877. }
  28878. public function getChangeDate($identifier)
  28879. {
  28880. $identifier = '/' . trim($identifier, '/') . '/';
  28881. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  28882. if (!empty($match[2])) {
  28883. $path = $match[1];
  28884. $rev = $match[2];
  28885. } else {
  28886. $path = $identifier;
  28887. $rev = '';
  28888. }
  28889. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  28890. foreach ($this->process->splitLines($output) as $line) {
  28891. if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  28892. return new \DateTime($match[1], new \DateTimeZone('UTC'));
  28893. }
  28894. }
  28895. return null;
  28896. }
  28897. public function getTags()
  28898. {
  28899. if (null === $this->tags) {
  28900. $this->tags = array();
  28901. if ($this->tagsPath !== false) {
  28902. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  28903. if ($output) {
  28904. foreach ($this->process->splitLines($output) as $line) {
  28905. $line = trim($line);
  28906. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  28907. if (isset($match[1], $match[2]) && $match[2] !== './') {
  28908. $this->tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  28909. '/' . $this->tagsPath . '/' . $match[2],
  28910. $match[1]
  28911. );
  28912. }
  28913. }
  28914. }
  28915. }
  28916. }
  28917. }
  28918. return $this->tags;
  28919. }
  28920. public function getBranches()
  28921. {
  28922. if (null === $this->branches) {
  28923. $this->branches = array();
  28924. if (false === $this->trunkPath) {
  28925. $trunkParent = $this->baseUrl . '/';
  28926. } else {
  28927. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  28928. }
  28929. $output = $this->execute('svn ls --verbose', $trunkParent);
  28930. if ($output) {
  28931. foreach ($this->process->splitLines($output) as $line) {
  28932. $line = trim($line);
  28933. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  28934. if (isset($match[1], $match[2]) && $match[2] === './') {
  28935. $this->branches['trunk'] = $this->buildIdentifier(
  28936. '/' . $this->trunkPath,
  28937. $match[1]
  28938. );
  28939. $this->rootIdentifier = $this->branches['trunk'];
  28940. break;
  28941. }
  28942. }
  28943. }
  28944. }
  28945. unset($output);
  28946. if ($this->branchesPath !== false) {
  28947. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  28948. if ($output) {
  28949. foreach ($this->process->splitLines(trim($output)) as $line) {
  28950. $line = trim($line);
  28951. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  28952. if (isset($match[1], $match[2]) && $match[2] !== './') {
  28953. $this->branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  28954. '/' . $this->branchesPath . '/' . $match[2],
  28955. $match[1]
  28956. );
  28957. }
  28958. }
  28959. }
  28960. }
  28961. }
  28962. }
  28963. return $this->branches;
  28964. }
  28965. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  28966. {
  28967. $url = self::normalizeUrl($url);
  28968. if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  28969. return true;
  28970. }
  28971. if (!$deep && !Filesystem::isLocalPath($url)) {
  28972. return false;
  28973. }
  28974. $process = new ProcessExecutor($io);
  28975. $exit = $process->execute(
  28976. "svn info --non-interactive -- ".ProcessExecutor::escape($url),
  28977. $ignoredOutput
  28978. );
  28979. if ($exit === 0) {
  28980. return true;
  28981. }
  28982. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  28983. return true;
  28984. }
  28985. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  28986. return true;
  28987. }
  28988. return false;
  28989. }
  28990. protected static function normalizeUrl($url)
  28991. {
  28992. $fs = new Filesystem();
  28993. if ($fs->isAbsolutePath($url)) {
  28994. return 'file://' . strtr($url, '\\', '/');
  28995. }
  28996. return $url;
  28997. }
  28998. protected function execute($command, $url)
  28999. {
  29000. if (null === $this->util) {
  29001. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  29002. $this->util->setCacheCredentials($this->cacheCredentials);
  29003. }
  29004. try {
  29005. return $this->util->execute($command, $url);
  29006. } catch (\RuntimeException $e) {
  29007. if (null === $this->util->binaryVersion()) {
  29008. 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());
  29009. }
  29010. throw new \RuntimeException(
  29011. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  29012. );
  29013. }
  29014. }
  29015. protected function buildIdentifier($baseDir, $revision)
  29016. {
  29017. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  29018. }
  29019. }
  29020. <?php
  29021. namespace Composer\Repository\Vcs;
  29022. use Composer\Cache;
  29023. use Composer\Downloader\TransportException;
  29024. use Composer\Config;
  29025. use Composer\IO\IOInterface;
  29026. use Composer\Json\JsonFile;
  29027. use Composer\Util\ProcessExecutor;
  29028. use Composer\Util\HttpDownloader;
  29029. use Composer\Util\Filesystem;
  29030. use Composer\Util\Http\Response;
  29031. abstract class VcsDriver implements VcsDriverInterface
  29032. {
  29033. protected $url;
  29034. protected $originUrl;
  29035. protected $repoConfig;
  29036. protected $io;
  29037. protected $config;
  29038. protected $process;
  29039. protected $httpDownloader;
  29040. protected $infoCache = array();
  29041. protected $cache;
  29042. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  29043. {
  29044. if (Filesystem::isLocalPath($repoConfig['url'])) {
  29045. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  29046. }
  29047. $this->url = $repoConfig['url'];
  29048. $this->originUrl = $repoConfig['url'];
  29049. $this->repoConfig = $repoConfig;
  29050. $this->io = $io;
  29051. $this->config = $config;
  29052. $this->httpDownloader = $httpDownloader;
  29053. $this->process = $process;
  29054. }
  29055. protected function shouldCache($identifier)
  29056. {
  29057. return $this->cache && preg_match('{^[a-f0-9]{40}$}iD', $identifier);
  29058. }
  29059. public function getComposerInformation($identifier)
  29060. {
  29061. if (!isset($this->infoCache[$identifier])) {
  29062. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  29063. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  29064. }
  29065. $composer = $this->getBaseComposerInformation($identifier);
  29066. if ($this->shouldCache($identifier)) {
  29067. $this->cache->write($identifier, JsonFile::encode($composer, 0));
  29068. }
  29069. $this->infoCache[$identifier] = $composer;
  29070. }
  29071. return $this->infoCache[$identifier];
  29072. }
  29073. protected function getBaseComposerInformation($identifier)
  29074. {
  29075. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  29076. if (!$composerFileContent) {
  29077. return null;
  29078. }
  29079. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  29080. if (empty($composer['time']) && $changeDate = $this->getChangeDate($identifier)) {
  29081. $composer['time'] = $changeDate->format(DATE_RFC3339);
  29082. }
  29083. return $composer;
  29084. }
  29085. public function hasComposerFile($identifier)
  29086. {
  29087. try {
  29088. return (bool) $this->getComposerInformation($identifier);
  29089. } catch (TransportException $e) {
  29090. }
  29091. return false;
  29092. }
  29093. protected function getScheme()
  29094. {
  29095. if (extension_loaded('openssl')) {
  29096. return 'https';
  29097. }
  29098. return 'http';
  29099. }
  29100. protected function getContents($url)
  29101. {
  29102. $options = isset($this->repoConfig['options']) ? $this->repoConfig['options'] : array();
  29103. return $this->httpDownloader->get($url, $options);
  29104. }
  29105. public function cleanup()
  29106. {
  29107. return;
  29108. }
  29109. }
  29110. <?php
  29111. namespace Composer\Repository\Vcs;
  29112. use Composer\Config;
  29113. use Composer\IO\IOInterface;
  29114. interface VcsDriverInterface
  29115. {
  29116. public function initialize();
  29117. public function getComposerInformation($identifier);
  29118. public function getFileContent($file, $identifier);
  29119. public function getChangeDate($identifier);
  29120. public function getRootIdentifier();
  29121. public function getBranches();
  29122. public function getTags();
  29123. public function getDist($identifier);
  29124. public function getSource($identifier);
  29125. public function getUrl();
  29126. public function hasComposerFile($identifier);
  29127. public function cleanup();
  29128. public static function supports(IOInterface $io, Config $config, $url, $deep = false);
  29129. }
  29130. <?php
  29131. namespace Composer\Repository;
  29132. use Composer\Downloader\TransportException;
  29133. use Composer\Repository\Vcs\VcsDriverInterface;
  29134. use Composer\Package\Version\VersionParser;
  29135. use Composer\Package\Loader\ArrayLoader;
  29136. use Composer\Package\Loader\ValidatingArrayLoader;
  29137. use Composer\Package\Loader\InvalidPackageException;
  29138. use Composer\Package\Loader\LoaderInterface;
  29139. use Composer\EventDispatcher\EventDispatcher;
  29140. use Composer\Util\ProcessExecutor;
  29141. use Composer\Util\HttpDownloader;
  29142. use Composer\Util\Url;
  29143. use Composer\Semver\Constraint\Constraint;
  29144. use Composer\IO\IOInterface;
  29145. use Composer\Config;
  29146. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  29147. {
  29148. protected $url;
  29149. protected $packageName;
  29150. protected $isVerbose;
  29151. protected $isVeryVerbose;
  29152. protected $io;
  29153. protected $config;
  29154. protected $versionParser;
  29155. protected $type;
  29156. protected $loader;
  29157. protected $repoConfig;
  29158. protected $httpDownloader;
  29159. protected $processExecutor;
  29160. protected $branchErrorOccurred = false;
  29161. private $drivers;
  29162. private $driver;
  29163. private $versionCache;
  29164. private $emptyReferences = array();
  29165. private $versionTransportExceptions = array();
  29166. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)
  29167. {
  29168. parent::__construct();
  29169. $this->drivers = $drivers ?: array(
  29170. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  29171. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  29172. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  29173. 'git' => 'Composer\Repository\Vcs\GitDriver',
  29174. 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
  29175. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  29176. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  29177. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  29178. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  29179. );
  29180. $this->url = $repoConfig['url'];
  29181. $this->io = $io;
  29182. $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
  29183. $this->isVerbose = $io->isVerbose();
  29184. $this->isVeryVerbose = $io->isVeryVerbose();
  29185. $this->config = $config;
  29186. $this->repoConfig = $repoConfig;
  29187. $this->versionCache = $versionCache;
  29188. $this->httpDownloader = $httpDownloader;
  29189. $this->processExecutor = $process ?: new ProcessExecutor($io);
  29190. }
  29191. public function getRepoName()
  29192. {
  29193. $driverClass = get_class($this->getDriver());
  29194. $driverType = array_search($driverClass, $this->drivers);
  29195. if (!$driverType) {
  29196. $driverType = $driverClass;
  29197. }
  29198. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  29199. }
  29200. public function getRepoConfig()
  29201. {
  29202. return $this->repoConfig;
  29203. }
  29204. public function setLoader(LoaderInterface $loader)
  29205. {
  29206. $this->loader = $loader;
  29207. }
  29208. public function getDriver()
  29209. {
  29210. if ($this->driver) {
  29211. return $this->driver;
  29212. }
  29213. if (isset($this->drivers[$this->type])) {
  29214. $class = $this->drivers[$this->type];
  29215. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  29216. $this->driver->initialize();
  29217. return $this->driver;
  29218. }
  29219. foreach ($this->drivers as $driver) {
  29220. if ($driver::supports($this->io, $this->config, $this->url)) {
  29221. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  29222. $this->driver->initialize();
  29223. return $this->driver;
  29224. }
  29225. }
  29226. foreach ($this->drivers as $driver) {
  29227. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  29228. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  29229. $this->driver->initialize();
  29230. return $this->driver;
  29231. }
  29232. }
  29233. return null;
  29234. }
  29235. public function hadInvalidBranches()
  29236. {
  29237. return $this->branchErrorOccurred;
  29238. }
  29239. public function getEmptyReferences()
  29240. {
  29241. return $this->emptyReferences;
  29242. }
  29243. public function getVersionTransportExceptions()
  29244. {
  29245. return $this->versionTransportExceptions;
  29246. }
  29247. protected function initialize()
  29248. {
  29249. parent::initialize();
  29250. $isVerbose = $this->isVerbose;
  29251. $isVeryVerbose = $this->isVeryVerbose;
  29252. $driver = $this->getDriver();
  29253. if (!$driver) {
  29254. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  29255. }
  29256. $this->versionParser = new VersionParser;
  29257. if (!$this->loader) {
  29258. $this->loader = new ArrayLoader($this->versionParser);
  29259. }
  29260. $hasRootIdentifierComposerJson = false;
  29261. try {
  29262. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  29263. if ($hasRootIdentifierComposerJson) {
  29264. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  29265. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  29266. }
  29267. } catch (\Exception $e) {
  29268. if ($isVeryVerbose) {
  29269. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  29270. }
  29271. }
  29272. foreach ($driver->getTags() as $tag => $identifier) {
  29273. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  29274. if ($isVeryVerbose) {
  29275. $this->io->writeError($msg);
  29276. } elseif ($isVerbose) {
  29277. $this->io->overwriteError($msg, false);
  29278. }
  29279. $tag = str_replace('release-', '', $tag);
  29280. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  29281. if ($cachedPackage) {
  29282. $this->addPackage($cachedPackage);
  29283. continue;
  29284. }
  29285. if ($cachedPackage === false) {
  29286. $this->emptyReferences[] = $identifier;
  29287. continue;
  29288. }
  29289. if (!$parsedTag = $this->validateTag($tag)) {
  29290. if ($isVeryVerbose) {
  29291. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  29292. }
  29293. continue;
  29294. }
  29295. try {
  29296. if (!$data = $driver->getComposerInformation($identifier)) {
  29297. if ($isVeryVerbose) {
  29298. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  29299. }
  29300. $this->emptyReferences[] = $identifier;
  29301. continue;
  29302. }
  29303. if (isset($data['version'])) {
  29304. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  29305. } else {
  29306. $data['version'] = $tag;
  29307. $data['version_normalized'] = $parsedTag;
  29308. }
  29309. $data['version'] = preg_replace('{[.-]?dev$}i', '', $data['version']);
  29310. $data['version_normalized'] = preg_replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  29311. unset($data['default-branch']);
  29312. if ($data['version_normalized'] !== $parsedTag) {
  29313. if ($isVeryVerbose) {
  29314. if (preg_match('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  29315. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  29316. } else {
  29317. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  29318. }
  29319. }
  29320. continue;
  29321. }
  29322. $tagPackageName = $this->packageName ?: (isset($data['name']) ? $data['name'] : '');
  29323. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  29324. if ($isVeryVerbose) {
  29325. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  29326. }
  29327. continue;
  29328. }
  29329. if ($isVeryVerbose) {
  29330. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  29331. }
  29332. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  29333. } catch (\Exception $e) {
  29334. if ($e instanceof TransportException) {
  29335. $this->versionTransportExceptions['tags'][$tag] = $e;
  29336. if ($e->getCode() === 404) {
  29337. $this->emptyReferences[] = $identifier;
  29338. }
  29339. if (in_array($e->getCode(), array(401, 403, 429), true)) {
  29340. throw $e;
  29341. }
  29342. }
  29343. if ($isVeryVerbose) {
  29344. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  29345. }
  29346. continue;
  29347. }
  29348. }
  29349. if (!$isVeryVerbose) {
  29350. $this->io->overwriteError('', false);
  29351. }
  29352. $branches = $driver->getBranches();
  29353. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  29354. $branches = array($driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]) + $branches;
  29355. }
  29356. foreach ($branches as $branch => $identifier) {
  29357. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  29358. if ($isVeryVerbose) {
  29359. $this->io->writeError($msg);
  29360. } elseif ($isVerbose) {
  29361. $this->io->overwriteError($msg, false);
  29362. }
  29363. if (!$parsedBranch = $this->validateBranch($branch)) {
  29364. if ($isVeryVerbose) {
  29365. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  29366. }
  29367. continue;
  29368. }
  29369. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  29370. $version = 'dev-' . $branch;
  29371. } else {
  29372. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  29373. $version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
  29374. }
  29375. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  29376. if ($cachedPackage) {
  29377. $this->addPackage($cachedPackage);
  29378. continue;
  29379. }
  29380. if ($cachedPackage === false) {
  29381. $this->emptyReferences[] = $identifier;
  29382. continue;
  29383. }
  29384. try {
  29385. if (!$data = $driver->getComposerInformation($identifier)) {
  29386. if ($isVeryVerbose) {
  29387. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  29388. }
  29389. $this->emptyReferences[] = $identifier;
  29390. continue;
  29391. }
  29392. $data['version'] = $version;
  29393. $data['version_normalized'] = $parsedBranch;
  29394. unset($data['default-branch']);
  29395. if ($driver->getRootIdentifier() === $branch) {
  29396. $data['default-branch'] = true;
  29397. }
  29398. if ($isVeryVerbose) {
  29399. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  29400. }
  29401. $packageData = $this->preProcess($driver, $data, $identifier);
  29402. $package = $this->loader->load($packageData);
  29403. if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
  29404. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  29405. }
  29406. $this->addPackage($package);
  29407. } catch (TransportException $e) {
  29408. $this->versionTransportExceptions['branches'][$branch] = $e;
  29409. if ($e->getCode() === 404) {
  29410. $this->emptyReferences[] = $identifier;
  29411. }
  29412. if (in_array($e->getCode(), array(401, 403, 429), true)) {
  29413. throw $e;
  29414. }
  29415. if ($isVeryVerbose) {
  29416. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  29417. }
  29418. continue;
  29419. } catch (\Exception $e) {
  29420. if (!$isVeryVerbose) {
  29421. $this->io->writeError('');
  29422. }
  29423. $this->branchErrorOccurred = true;
  29424. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  29425. $this->io->writeError('');
  29426. continue;
  29427. }
  29428. }
  29429. $driver->cleanup();
  29430. if (!$isVeryVerbose) {
  29431. $this->io->overwriteError('', false);
  29432. }
  29433. if (!$this->getPackages()) {
  29434. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  29435. }
  29436. }
  29437. protected function preProcess(VcsDriverInterface $driver, array $data, $identifier)
  29438. {
  29439. $dataPackageName = isset($data['name']) ? $data['name'] : null;
  29440. $data['name'] = $this->packageName ?: $dataPackageName;
  29441. if (!isset($data['dist'])) {
  29442. $data['dist'] = $driver->getDist($identifier);
  29443. }
  29444. if (!isset($data['source'])) {
  29445. $data['source'] = $driver->getSource($identifier);
  29446. }
  29447. return $data;
  29448. }
  29449. private function validateBranch($branch)
  29450. {
  29451. try {
  29452. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  29453. $this->versionParser->parseConstraints($normalizedBranch);
  29454. return $normalizedBranch;
  29455. } catch (\Exception $e) {
  29456. }
  29457. return false;
  29458. }
  29459. private function validateTag($version)
  29460. {
  29461. try {
  29462. return $this->versionParser->normalize($version);
  29463. } catch (\Exception $e) {
  29464. }
  29465. return false;
  29466. }
  29467. private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $isDefaultBranch = false)
  29468. {
  29469. if (!$this->versionCache) {
  29470. return null;
  29471. }
  29472. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  29473. if ($cachedPackage === false) {
  29474. if ($isVeryVerbose) {
  29475. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  29476. }
  29477. return false;
  29478. }
  29479. if ($cachedPackage) {
  29480. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  29481. if ($isVeryVerbose) {
  29482. $this->io->writeError($msg);
  29483. } elseif ($isVerbose) {
  29484. $this->io->overwriteError($msg, false);
  29485. }
  29486. unset($cachedPackage['default-branch']);
  29487. if ($isDefaultBranch) {
  29488. $cachedPackage['default-branch'] = true;
  29489. }
  29490. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  29491. if ($isVeryVerbose) {
  29492. $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>');
  29493. }
  29494. $cachedPackage = null;
  29495. }
  29496. }
  29497. if ($cachedPackage) {
  29498. return $this->loader->load($cachedPackage);
  29499. }
  29500. return null;
  29501. }
  29502. }
  29503. <?php
  29504. namespace Composer\Repository;
  29505. interface VersionCacheInterface
  29506. {
  29507. public function getVersionPackage($version, $identifier);
  29508. }
  29509. <?php
  29510. namespace Composer\Repository;
  29511. use Composer\Package\AliasPackage;
  29512. use Composer\Installer\InstallationManager;
  29513. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  29514. {
  29515. protected $devPackageNames = array();
  29516. public function setDevPackageNames(array $devPackageNames)
  29517. {
  29518. $this->devPackageNames = $devPackageNames;
  29519. }
  29520. public function getDevPackageNames()
  29521. {
  29522. return $this->devPackageNames;
  29523. }
  29524. public function write($devMode, InstallationManager $installationManager)
  29525. {
  29526. }
  29527. public function reload()
  29528. {
  29529. }
  29530. public function getCanonicalPackages()
  29531. {
  29532. $packages = $this->getPackages();
  29533. $packagesByName = array();
  29534. foreach ($packages as $package) {
  29535. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  29536. $packagesByName[$package->getName()] = $package;
  29537. }
  29538. }
  29539. $canonicalPackages = array();
  29540. foreach ($packagesByName as $package) {
  29541. while ($package instanceof AliasPackage) {
  29542. $package = $package->getAliasOf();
  29543. }
  29544. $canonicalPackages[] = $package;
  29545. }
  29546. return $canonicalPackages;
  29547. }
  29548. }
  29549. <?php
  29550. namespace Composer\Repository;
  29551. use Composer\Package\PackageInterface;
  29552. use Composer\Installer\InstallationManager;
  29553. interface WritableRepositoryInterface extends RepositoryInterface
  29554. {
  29555. public function write($devMode, InstallationManager $installationManager);
  29556. public function addPackage(PackageInterface $package);
  29557. public function removePackage(PackageInterface $package);
  29558. public function getCanonicalPackages();
  29559. public function reload();
  29560. public function setDevPackageNames(array $devPackageNames);
  29561. public function getDevPackageNames();
  29562. }
  29563. <?php
  29564. namespace Composer\Script;
  29565. use Composer\Composer;
  29566. use Composer\IO\IOInterface;
  29567. use Composer\EventDispatcher\Event as BaseEvent;
  29568. class Event extends BaseEvent
  29569. {
  29570. private $composer;
  29571. private $io;
  29572. private $devMode;
  29573. private $originatingEvent;
  29574. public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array())
  29575. {
  29576. parent::__construct($name, $args, $flags);
  29577. $this->composer = $composer;
  29578. $this->io = $io;
  29579. $this->devMode = $devMode;
  29580. }
  29581. public function getComposer()
  29582. {
  29583. return $this->composer;
  29584. }
  29585. public function getIO()
  29586. {
  29587. return $this->io;
  29588. }
  29589. public function isDevMode()
  29590. {
  29591. return $this->devMode;
  29592. }
  29593. public function getOriginatingEvent()
  29594. {
  29595. return $this->originatingEvent;
  29596. }
  29597. public function setOriginatingEvent(BaseEvent $event)
  29598. {
  29599. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  29600. return $this;
  29601. }
  29602. private function calculateOriginatingEvent(BaseEvent $event)
  29603. {
  29604. if ($event instanceof Event && $event->getOriginatingEvent()) {
  29605. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  29606. }
  29607. return $event;
  29608. }
  29609. }
  29610. <?php
  29611. namespace Composer\Script;
  29612. class ScriptEvents
  29613. {
  29614. const PRE_INSTALL_CMD = 'pre-install-cmd';
  29615. const POST_INSTALL_CMD = 'post-install-cmd';
  29616. const PRE_UPDATE_CMD = 'pre-update-cmd';
  29617. const POST_UPDATE_CMD = 'post-update-cmd';
  29618. const PRE_STATUS_CMD = 'pre-status-cmd';
  29619. const POST_STATUS_CMD = 'post-status-cmd';
  29620. const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  29621. const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  29622. const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  29623. const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  29624. const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  29625. const POST_ARCHIVE_CMD = 'post-archive-cmd';
  29626. }
  29627. <?php
  29628. namespace Composer\SelfUpdate;
  29629. class Keys
  29630. {
  29631. public static function fingerprint($path)
  29632. {
  29633. $hash = strtoupper(hash('sha256', preg_replace('{\s}', '', file_get_contents($path))));
  29634. return implode(' ', array(
  29635. substr($hash, 0, 8),
  29636. substr($hash, 8, 8),
  29637. substr($hash, 16, 8),
  29638. substr($hash, 24, 8),
  29639. '',
  29640. substr($hash, 32, 8),
  29641. substr($hash, 40, 8),
  29642. substr($hash, 48, 8),
  29643. substr($hash, 56, 8),
  29644. ));
  29645. }
  29646. }
  29647. <?php
  29648. namespace Composer\SelfUpdate;
  29649. use Composer\Util\HttpDownloader;
  29650. use Composer\Config;
  29651. class Versions
  29652. {
  29653. public static $channels = array('stable', 'preview', 'snapshot', '1', '2');
  29654. private $httpDownloader;
  29655. private $config;
  29656. private $channel;
  29657. private $versionsData;
  29658. public function __construct(Config $config, HttpDownloader $httpDownloader)
  29659. {
  29660. $this->httpDownloader = $httpDownloader;
  29661. $this->config = $config;
  29662. }
  29663. public function getChannel()
  29664. {
  29665. if ($this->channel) {
  29666. return $this->channel;
  29667. }
  29668. $channelFile = $this->config->get('home').'/update-channel';
  29669. if (file_exists($channelFile)) {
  29670. $channel = trim(file_get_contents($channelFile));
  29671. if (in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
  29672. return $this->channel = $channel;
  29673. }
  29674. }
  29675. return $this->channel = 'stable';
  29676. }
  29677. public function setChannel($channel)
  29678. {
  29679. if (!in_array($channel, self::$channels, true)) {
  29680. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels));
  29681. }
  29682. $channelFile = $this->config->get('home').'/update-channel';
  29683. $this->channel = $channel;
  29684. file_put_contents($channelFile, (is_numeric($channel) ? 'stable' : $channel).PHP_EOL);
  29685. }
  29686. public function getLatest($channel = null)
  29687. {
  29688. $versions = $this->getVersionsData();
  29689. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  29690. if ($version['min-php'] <= PHP_VERSION_ID) {
  29691. return $version;
  29692. }
  29693. }
  29694. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  29695. }
  29696. private function getVersionsData()
  29697. {
  29698. if (!$this->versionsData) {
  29699. if ($this->config->get('disable-tls') === true) {
  29700. $protocol = 'http';
  29701. } else {
  29702. $protocol = 'https';
  29703. }
  29704. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  29705. }
  29706. return $this->versionsData;
  29707. }
  29708. }
  29709. <?php
  29710. namespace Composer\Util;
  29711. use Composer\Config;
  29712. use Composer\IO\IOInterface;
  29713. use Composer\Downloader\TransportException;
  29714. class AuthHelper
  29715. {
  29716. protected $io;
  29717. protected $config;
  29718. private $displayedOriginAuthentications = array();
  29719. public function __construct(IOInterface $io, Config $config)
  29720. {
  29721. $this->io = $io;
  29722. $this->config = $config;
  29723. }
  29724. public function storeAuth($origin, $storeAuth)
  29725. {
  29726. $store = false;
  29727. $configSource = $this->config->getAuthConfigSource();
  29728. if ($storeAuth === true) {
  29729. $store = $configSource;
  29730. } elseif ($storeAuth === 'prompt') {
  29731. $answer = $this->io->askAndValidate(
  29732. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  29733. function ($value) {
  29734. $input = strtolower(substr(trim($value), 0, 1));
  29735. if (in_array($input, array('y','n'))) {
  29736. return $input;
  29737. }
  29738. throw new \RuntimeException('Please answer (y)es or (n)o');
  29739. },
  29740. null,
  29741. 'y'
  29742. );
  29743. if ($answer === 'y') {
  29744. $store = $configSource;
  29745. }
  29746. }
  29747. if ($store) {
  29748. $store->addConfigSetting(
  29749. 'http-basic.'.$origin,
  29750. $this->io->getAuthentication($origin)
  29751. );
  29752. }
  29753. }
  29754. public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array())
  29755. {
  29756. $storeAuth = false;
  29757. if (in_array($origin, $this->config->get('github-domains'), true)) {
  29758. $gitHubUtil = new GitHub($this->io, $this->config, null);
  29759. $message = "\n";
  29760. $rateLimited = $gitHubUtil->isRateLimited($headers);
  29761. if ($rateLimited) {
  29762. $rateLimit = $gitHubUtil->getRateLimit($headers);
  29763. if ($this->io->hasAuthentication($origin)) {
  29764. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  29765. } else {
  29766. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  29767. }
  29768. $message = sprintf(
  29769. '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.',
  29770. $rateLimit['limit'],
  29771. $rateLimit['reset']
  29772. )."\n";
  29773. } else {
  29774. $message .= 'Could not fetch '.$url.', please ';
  29775. if ($this->io->hasAuthentication($origin)) {
  29776. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  29777. } else {
  29778. $message .= 'create a GitHub OAuth token to access private repos';
  29779. }
  29780. }
  29781. if (!$gitHubUtil->authorizeOAuth($origin)
  29782. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  29783. ) {
  29784. throw new TransportException('Could not authenticate against '.$origin, 401);
  29785. }
  29786. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  29787. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  29788. $gitLabUtil = new GitLab($this->io, $this->config, null);
  29789. if ($this->io->hasAuthentication($origin)) {
  29790. $auth = $this->io->getAuthentication($origin);
  29791. if (in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) {
  29792. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  29793. }
  29794. }
  29795. if (!$gitLabUtil->authorizeOAuth($origin)
  29796. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  29797. ) {
  29798. throw new TransportException('Could not authenticate against '.$origin, 401);
  29799. }
  29800. } elseif ($origin === 'bitbucket.org' || $origin === 'api.bitbucket.org') {
  29801. $askForOAuthToken = true;
  29802. $origin = 'bitbucket.org';
  29803. if ($this->io->hasAuthentication($origin)) {
  29804. $auth = $this->io->getAuthentication($origin);
  29805. if ($auth['username'] !== 'x-token-auth') {
  29806. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  29807. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  29808. if (!empty($accessToken)) {
  29809. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  29810. $askForOAuthToken = false;
  29811. }
  29812. } else {
  29813. throw new TransportException('Could not authenticate against ' . $origin, 401);
  29814. }
  29815. }
  29816. if ($askForOAuthToken) {
  29817. $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');
  29818. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  29819. if (!$bitBucketUtil->authorizeOAuth($origin)
  29820. && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  29821. ) {
  29822. throw new TransportException('Could not authenticate against ' . $origin, 401);
  29823. }
  29824. }
  29825. } else {
  29826. if ($statusCode === 404) {
  29827. return null;
  29828. }
  29829. if (!$this->io->isInteractive()) {
  29830. if ($statusCode === 401) {
  29831. $message = "The '" . $url . "' URL required authentication.\nYou must be using the interactive console to authenticate";
  29832. } elseif ($statusCode === 403) {
  29833. $message = "The '" . $url . "' URL could not be accessed: " . $reason;
  29834. } else {
  29835. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  29836. }
  29837. throw new TransportException($message, $statusCode);
  29838. }
  29839. if ($this->io->hasAuthentication($origin)) {
  29840. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  29841. }
  29842. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  29843. $username = $this->io->ask(' Username: ');
  29844. $password = $this->io->askAndHideAnswer(' Password: ');
  29845. $this->io->setAuthentication($origin, $username, $password);
  29846. $storeAuth = $this->config->get('store-auths');
  29847. }
  29848. return array('retry' => true, 'storeAuth' => $storeAuth);
  29849. }
  29850. public function addAuthenticationHeader(array $headers, $origin, $url)
  29851. {
  29852. if ($this->io->hasAuthentication($origin)) {
  29853. $authenticationDisplayMessage = null;
  29854. $auth = $this->io->getAuthentication($origin);
  29855. if ($auth['password'] === 'bearer') {
  29856. $headers[] = 'Authorization: Bearer '.$auth['username'];
  29857. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  29858. if (preg_match('{^https?://api\.github\.com/}', $url)) {
  29859. $headers[] = 'Authorization: token '.$auth['username'];
  29860. $authenticationDisplayMessage = 'Using GitHub token authentication';
  29861. }
  29862. } elseif (
  29863. in_array($origin, $this->config->get('gitlab-domains'), true)
  29864. && in_array($auth['password'], array('oauth2', 'private-token', 'gitlab-ci-token'), true)
  29865. ) {
  29866. if ($auth['password'] === 'oauth2') {
  29867. $headers[] = 'Authorization: Bearer '.$auth['username'];
  29868. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  29869. } else {
  29870. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  29871. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  29872. }
  29873. } elseif (
  29874. 'bitbucket.org' === $origin
  29875. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  29876. && 'x-token-auth' === $auth['username']
  29877. ) {
  29878. if (!$this->isPublicBitBucketDownload($url)) {
  29879. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  29880. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  29881. }
  29882. } else {
  29883. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  29884. $headers[] = 'Authorization: Basic '.$authStr;
  29885. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  29886. }
  29887. if ($authenticationDisplayMessage && (!isset($this->displayedOriginAuthentications[$origin]) || $this->displayedOriginAuthentications[$origin] !== $authenticationDisplayMessage)) {
  29888. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  29889. $this->displayedOriginAuthentications[$origin] = $authenticationDisplayMessage;
  29890. }
  29891. } elseif (in_array($origin, array('api.bitbucket.org', 'api.github.com'), true)) {
  29892. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  29893. }
  29894. return $headers;
  29895. }
  29896. public function isPublicBitBucketDownload($urlToBitBucketFile)
  29897. {
  29898. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  29899. if (strpos($domain, 'bitbucket.org') === false) {
  29900. return true;
  29901. }
  29902. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  29903. $pathParts = explode('/', $path);
  29904. return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
  29905. }
  29906. }
  29907. <?php
  29908. namespace Composer\Util;
  29909. use Composer\Factory;
  29910. use Composer\IO\IOInterface;
  29911. use Composer\Config;
  29912. use Composer\Downloader\TransportException;
  29913. class Bitbucket
  29914. {
  29915. private $io;
  29916. private $config;
  29917. private $process;
  29918. private $httpDownloader;
  29919. private $token = null;
  29920. private $time;
  29921. const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  29922. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null, $time = null)
  29923. {
  29924. $this->io = $io;
  29925. $this->config = $config;
  29926. $this->process = $process ?: new ProcessExecutor($io);
  29927. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29928. $this->time = $time;
  29929. }
  29930. public function getToken()
  29931. {
  29932. if (!isset($this->token['access_token'])) {
  29933. return '';
  29934. }
  29935. return $this->token['access_token'];
  29936. }
  29937. public function authorizeOAuth($originUrl)
  29938. {
  29939. if ($originUrl !== 'bitbucket.org') {
  29940. return false;
  29941. }
  29942. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  29943. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  29944. return true;
  29945. }
  29946. return false;
  29947. }
  29948. private function requestAccessToken()
  29949. {
  29950. try {
  29951. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
  29952. 'retry-auth-failure' => false,
  29953. 'http' => array(
  29954. 'method' => 'POST',
  29955. 'content' => 'grant_type=client_credentials',
  29956. ),
  29957. ));
  29958. $token = $response->decodeJson();
  29959. if (!isset($token['expires_in']) || !isset($token['access_token'])) {
  29960. throw new \LogicException('Expected a token configured with expires_in and access_token present, got '.json_encode($token));
  29961. }
  29962. $this->token = $token;
  29963. } catch (TransportException $e) {
  29964. if ($e->getCode() === 400) {
  29965. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  29966. $this->io->writeError('This can have two reasons:');
  29967. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  29968. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  29969. return false;
  29970. }
  29971. if (in_array($e->getCode(), array(403, 401))) {
  29972. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  29973. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  29974. return false;
  29975. }
  29976. throw $e;
  29977. }
  29978. return true;
  29979. }
  29980. public function authorizeOAuthInteractively($originUrl, $message = null)
  29981. {
  29982. if ($message) {
  29983. $this->io->writeError($message);
  29984. }
  29985. $url = 'https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/';
  29986. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  29987. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  29988. $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)');
  29989. $consumerKey = trim((string) $this->io->askAndHideAnswer('Consumer Key (hidden): '));
  29990. if (!$consumerKey) {
  29991. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  29992. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  29993. return false;
  29994. }
  29995. $consumerSecret = trim((string) $this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  29996. if (!$consumerSecret) {
  29997. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  29998. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  29999. return false;
  30000. }
  30001. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  30002. if (!$this->requestAccessToken()) {
  30003. return false;
  30004. }
  30005. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  30006. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  30007. $this->io->writeError('<info>Consumer stored successfully.</info>');
  30008. return true;
  30009. }
  30010. public function requestToken($originUrl, $consumerKey, $consumerSecret)
  30011. {
  30012. if ($this->token !== null || $this->getTokenFromConfig($originUrl)) {
  30013. return $this->token['access_token'];
  30014. }
  30015. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  30016. if (!$this->requestAccessToken()) {
  30017. return '';
  30018. }
  30019. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  30020. if (!isset($this->token['access_token'])) {
  30021. throw new \LogicException('Failed to initialize token above');
  30022. }
  30023. return $this->token['access_token'];
  30024. }
  30025. private function storeInAuthConfig($originUrl, $consumerKey, $consumerSecret)
  30026. {
  30027. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  30028. if (null === $this->token || !isset($this->token['expires_in'])) {
  30029. throw new \LogicException('Expected a token configured with expires_in present, got '.json_encode($this->token));
  30030. }
  30031. $time = null === $this->time ? time() : $this->time;
  30032. $consumer = array(
  30033. "consumer-key" => $consumerKey,
  30034. "consumer-secret" => $consumerSecret,
  30035. "access-token" => $this->token['access_token'],
  30036. "access-token-expiration" => $time + $this->token['expires_in'],
  30037. );
  30038. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  30039. }
  30040. private function getTokenFromConfig($originUrl)
  30041. {
  30042. $authConfig = $this->config->get('bitbucket-oauth');
  30043. if (
  30044. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  30045. || time() > $authConfig[$originUrl]['access-token-expiration']
  30046. ) {
  30047. return false;
  30048. }
  30049. $this->token = array(
  30050. 'access_token' => $authConfig[$originUrl]['access-token'],
  30051. );
  30052. return true;
  30053. }
  30054. }
  30055. <?php
  30056. namespace Composer\Util;
  30057. class ComposerMirror
  30058. {
  30059. public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type, $prettyVersion = null)
  30060. {
  30061. if ($reference) {
  30062. $reference = preg_match('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  30063. }
  30064. $version = strpos($version, '/') === false ? $version : md5($version);
  30065. $from = array('%package%', '%version%', '%reference%', '%type%');
  30066. $to = array($packageName, $version, $reference, $type);
  30067. if (null !== $prettyVersion) {
  30068. $from[] = '%prettyVersion%';
  30069. $to[] = $prettyVersion;
  30070. }
  30071. return str_replace($from, $to, $mirrorUrl);
  30072. }
  30073. public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
  30074. {
  30075. if (preg_match('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  30076. $url = 'gh-'.$match[1].'/'.$match[2];
  30077. } elseif (preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  30078. $url = 'bb-'.$match[1].'/'.$match[2];
  30079. } else {
  30080. $url = preg_replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  30081. }
  30082. return str_replace(
  30083. array('%package%', '%normalizedUrl%', '%type%'),
  30084. array($packageName, $url, $type),
  30085. $mirrorUrl
  30086. );
  30087. }
  30088. public static function processHgUrl($mirrorUrl, $packageName, $url, $type)
  30089. {
  30090. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  30091. }
  30092. }
  30093. <?php
  30094. namespace Composer\Util;
  30095. use Composer\Package\Loader\ArrayLoader;
  30096. use Composer\Package\Loader\ValidatingArrayLoader;
  30097. use Composer\Package\Loader\InvalidPackageException;
  30098. use Composer\Json\JsonValidationException;
  30099. use Composer\IO\IOInterface;
  30100. use Composer\Json\JsonFile;
  30101. use Composer\Spdx\SpdxLicenses;
  30102. class ConfigValidator
  30103. {
  30104. const CHECK_VERSION = 1;
  30105. private $io;
  30106. public function __construct(IOInterface $io)
  30107. {
  30108. $this->io = $io;
  30109. }
  30110. public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, $flags = self::CHECK_VERSION)
  30111. {
  30112. $errors = array();
  30113. $publishErrors = array();
  30114. $warnings = array();
  30115. $laxValid = false;
  30116. try {
  30117. $json = new JsonFile($file, null, $this->io);
  30118. $manifest = $json->read();
  30119. $json->validateSchema(JsonFile::LAX_SCHEMA);
  30120. $laxValid = true;
  30121. $json->validateSchema();
  30122. } catch (JsonValidationException $e) {
  30123. foreach ($e->getErrors() as $message) {
  30124. if ($laxValid) {
  30125. $publishErrors[] = $message;
  30126. } else {
  30127. $errors[] = $message;
  30128. }
  30129. }
  30130. } catch (\Exception $e) {
  30131. $errors[] = $e->getMessage();
  30132. return array($errors, $publishErrors, $warnings);
  30133. }
  30134. if (empty($manifest['license'])) {
  30135. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  30136. } else {
  30137. $licenses = (array) $manifest['license'];
  30138. foreach ($licenses as $key => $license) {
  30139. if ('proprietary' === $license) {
  30140. unset($licenses[$key]);
  30141. }
  30142. }
  30143. $licenseValidator = new SpdxLicenses();
  30144. foreach ($licenses as $license) {
  30145. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  30146. if ($spdxLicense && $spdxLicense[3]) {
  30147. if (preg_match('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  30148. $warnings[] = sprintf(
  30149. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  30150. $license
  30151. );
  30152. } elseif (preg_match('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  30153. $warnings[] = sprintf(
  30154. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  30155. $license
  30156. );
  30157. } else {
  30158. $warnings[] = sprintf(
  30159. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  30160. $license
  30161. );
  30162. }
  30163. }
  30164. }
  30165. }
  30166. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  30167. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  30168. }
  30169. if (!empty($manifest['name']) && preg_match('{[A-Z]}', $manifest['name'])) {
  30170. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  30171. $suggestName = strtolower($suggestName);
  30172. $publishErrors[] = sprintf(
  30173. '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.',
  30174. $manifest['name'],
  30175. $suggestName
  30176. );
  30177. }
  30178. if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') {
  30179. $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.";
  30180. }
  30181. if (isset($manifest['require'], $manifest['require-dev'])) {
  30182. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  30183. if (!empty($requireOverrides)) {
  30184. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  30185. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  30186. }
  30187. }
  30188. foreach (array('provide', 'replace') as $linkType) {
  30189. if (isset($manifest[$linkType])) {
  30190. foreach (array('require', 'require-dev') as $requireType) {
  30191. if (isset($manifest[$requireType])) {
  30192. foreach ($manifest[$linkType] as $provide => $constraint) {
  30193. if (isset($manifest[$requireType][$provide])) {
  30194. $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.';
  30195. }
  30196. }
  30197. }
  30198. }
  30199. }
  30200. }
  30201. $require = isset($manifest['require']) ? $manifest['require'] : array();
  30202. $requireDev = isset($manifest['require-dev']) ? $manifest['require-dev'] : array();
  30203. $packages = array_merge($require, $requireDev);
  30204. foreach ($packages as $package => $version) {
  30205. if (preg_match('/#/', $version) === 1) {
  30206. $warnings[] = sprintf(
  30207. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  30208. $package
  30209. );
  30210. }
  30211. }
  30212. $scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
  30213. $scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
  30214. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  30215. if (!array_key_exists($scriptName, $scripts)) {
  30216. $warnings[] = sprintf(
  30217. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  30218. $scriptName
  30219. );
  30220. }
  30221. }
  30222. if (isset($manifest['autoload']['psr-0'][''])) {
  30223. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  30224. }
  30225. if (isset($manifest['autoload']['psr-4'][''])) {
  30226. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  30227. }
  30228. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  30229. try {
  30230. if (!isset($manifest['version'])) {
  30231. $manifest['version'] = '1.0.0';
  30232. }
  30233. if (!isset($manifest['name'])) {
  30234. $manifest['name'] = 'dummy/dummy';
  30235. }
  30236. $loader->load($manifest);
  30237. } catch (InvalidPackageException $e) {
  30238. $errors = array_merge($errors, $e->getErrors());
  30239. }
  30240. $warnings = array_merge($warnings, $loader->getWarnings());
  30241. return array($errors, $publishErrors, $warnings);
  30242. }
  30243. }
  30244. <?php
  30245. namespace Composer\Util;
  30246. use Composer\IO\IOInterface;
  30247. class ErrorHandler
  30248. {
  30249. private static $io;
  30250. public static function handle($level, $message, $file, $line)
  30251. {
  30252. if (!(error_reporting() & $level)) {
  30253. return true;
  30254. }
  30255. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  30256. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  30257. "\na legitimately suppressed error that you were not supposed to see.";
  30258. }
  30259. if ($level !== E_DEPRECATED && $level !== E_USER_DEPRECATED) {
  30260. throw new \ErrorException($message, 0, $level, $file, $line);
  30261. }
  30262. if (self::$io) {
  30263. if (preg_match('{^Return type of Symfony\\\\.*ReturnTypeWillChange}is', $message)) {
  30264. return true;
  30265. }
  30266. if (strpos(strtr($file, '\\', '/'), 'vendor/symfony/') !== false) {
  30267. return true;
  30268. }
  30269. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  30270. if (self::$io->isVerbose()) {
  30271. self::$io->writeError('<warning>Stack trace:</warning>');
  30272. self::$io->writeError(array_filter(array_map(function ($a) {
  30273. if (isset($a['line'], $a['file'])) {
  30274. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  30275. }
  30276. return null;
  30277. }, array_slice(debug_backtrace(), 2))));
  30278. }
  30279. }
  30280. return true;
  30281. }
  30282. public static function register(IOInterface $io = null)
  30283. {
  30284. set_error_handler(array(__CLASS__, 'handle'));
  30285. error_reporting(E_ALL | E_STRICT);
  30286. self::$io = $io;
  30287. }
  30288. }
  30289. <?php
  30290. namespace Composer\Util;
  30291. use React\Promise\PromiseInterface;
  30292. use RecursiveDirectoryIterator;
  30293. use RecursiveIteratorIterator;
  30294. use Symfony\Component\Filesystem\Exception\IOException;
  30295. use Symfony\Component\Finder\Finder;
  30296. class Filesystem
  30297. {
  30298. private $processExecutor;
  30299. public function __construct(ProcessExecutor $executor = null)
  30300. {
  30301. $this->processExecutor = $executor;
  30302. }
  30303. public function remove($file)
  30304. {
  30305. if (is_dir($file)) {
  30306. return $this->removeDirectory($file);
  30307. }
  30308. if (file_exists($file)) {
  30309. return $this->unlink($file);
  30310. }
  30311. return false;
  30312. }
  30313. public function isDirEmpty($dir)
  30314. {
  30315. $finder = Finder::create()
  30316. ->ignoreVCS(false)
  30317. ->ignoreDotFiles(false)
  30318. ->depth(0)
  30319. ->in($dir);
  30320. return \count($finder) === 0;
  30321. }
  30322. public function emptyDirectory($dir, $ensureDirectoryExists = true)
  30323. {
  30324. if (is_link($dir) && file_exists($dir)) {
  30325. $this->unlink($dir);
  30326. }
  30327. if ($ensureDirectoryExists) {
  30328. $this->ensureDirectoryExists($dir);
  30329. }
  30330. if (is_dir($dir)) {
  30331. $finder = Finder::create()
  30332. ->ignoreVCS(false)
  30333. ->ignoreDotFiles(false)
  30334. ->depth(0)
  30335. ->in($dir);
  30336. foreach ($finder as $path) {
  30337. $this->remove((string) $path);
  30338. }
  30339. }
  30340. }
  30341. public function removeDirectory($directory)
  30342. {
  30343. $edgeCaseResult = $this->removeEdgeCases($directory);
  30344. if ($edgeCaseResult !== null) {
  30345. return $edgeCaseResult;
  30346. }
  30347. if (Platform::isWindows()) {
  30348. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  30349. } else {
  30350. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  30351. }
  30352. $result = $this->getProcess()->execute($cmd, $output) === 0;
  30353. clearstatcache();
  30354. if ($result && !is_dir($directory)) {
  30355. return true;
  30356. }
  30357. return $this->removeDirectoryPhp($directory);
  30358. }
  30359. public function removeDirectoryAsync($directory)
  30360. {
  30361. $edgeCaseResult = $this->removeEdgeCases($directory);
  30362. if ($edgeCaseResult !== null) {
  30363. return \React\Promise\resolve($edgeCaseResult);
  30364. }
  30365. if (Platform::isWindows()) {
  30366. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  30367. } else {
  30368. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  30369. }
  30370. $promise = $this->getProcess()->executeAsync($cmd);
  30371. $self = $this;
  30372. return $promise->then(function ($process) use ($directory, $self) {
  30373. clearstatcache();
  30374. if ($process->isSuccessful()) {
  30375. if (!is_dir($directory)) {
  30376. return \React\Promise\resolve(true);
  30377. }
  30378. }
  30379. return \React\Promise\resolve($self->removeDirectoryPhp($directory));
  30380. });
  30381. }
  30382. private function removeEdgeCases($directory, $fallbackToPhp = true)
  30383. {
  30384. if ($this->isSymlinkedDirectory($directory)) {
  30385. return $this->unlinkSymlinkedDirectory($directory);
  30386. }
  30387. if ($this->isJunction($directory)) {
  30388. return $this->removeJunction($directory);
  30389. }
  30390. if (is_link($directory)) {
  30391. return unlink($directory);
  30392. }
  30393. if (!is_dir($directory) || !file_exists($directory)) {
  30394. return true;
  30395. }
  30396. if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  30397. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  30398. }
  30399. if (!\function_exists('proc_open') && $fallbackToPhp) {
  30400. return $this->removeDirectoryPhp($directory);
  30401. }
  30402. return null;
  30403. }
  30404. public function removeDirectoryPhp($directory)
  30405. {
  30406. $edgeCaseResult = $this->removeEdgeCases($directory, false);
  30407. if ($edgeCaseResult !== null) {
  30408. return $edgeCaseResult;
  30409. }
  30410. try {
  30411. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  30412. } catch (\UnexpectedValueException $e) {
  30413. clearstatcache();
  30414. usleep(100000);
  30415. if (!is_dir($directory)) {
  30416. return true;
  30417. }
  30418. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  30419. }
  30420. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  30421. foreach ($ri as $file) {
  30422. if ($file->isDir()) {
  30423. $this->rmdir($file->getPathname());
  30424. } else {
  30425. $this->unlink($file->getPathname());
  30426. }
  30427. }
  30428. unset($ri, $it, $file);
  30429. return $this->rmdir($directory);
  30430. }
  30431. public function ensureDirectoryExists($directory)
  30432. {
  30433. if (!is_dir($directory)) {
  30434. if (file_exists($directory)) {
  30435. throw new \RuntimeException(
  30436. $directory.' exists and is not a directory.'
  30437. );
  30438. }
  30439. if (!@mkdir($directory, 0777, true)) {
  30440. throw new \RuntimeException(
  30441. $directory.' does not exist and could not be created.'
  30442. );
  30443. }
  30444. }
  30445. }
  30446. public function unlink($path)
  30447. {
  30448. $unlinked = @$this->unlinkImplementation($path);
  30449. if (!$unlinked) {
  30450. if (Platform::isWindows()) {
  30451. usleep(350000);
  30452. $unlinked = @$this->unlinkImplementation($path);
  30453. }
  30454. if (!$unlinked) {
  30455. $error = error_get_last();
  30456. $message = 'Could not delete '.$path.': ' . @$error['message'];
  30457. if (Platform::isWindows()) {
  30458. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  30459. }
  30460. throw new \RuntimeException($message);
  30461. }
  30462. }
  30463. return true;
  30464. }
  30465. public function rmdir($path)
  30466. {
  30467. $deleted = @rmdir($path);
  30468. if (!$deleted) {
  30469. if (Platform::isWindows()) {
  30470. usleep(350000);
  30471. $deleted = @rmdir($path);
  30472. }
  30473. if (!$deleted) {
  30474. $error = error_get_last();
  30475. $message = 'Could not delete '.$path.': ' . @$error['message'];
  30476. if (Platform::isWindows()) {
  30477. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  30478. }
  30479. throw new \RuntimeException($message);
  30480. }
  30481. }
  30482. return true;
  30483. }
  30484. public function copyThenRemove($source, $target)
  30485. {
  30486. $this->copy($source, $target);
  30487. if (!is_dir($source)) {
  30488. $this->unlink($source);
  30489. return;
  30490. }
  30491. $this->removeDirectoryPhp($source);
  30492. }
  30493. public function copy($source, $target)
  30494. {
  30495. if (!is_dir($source)) {
  30496. return copy($source, $target);
  30497. }
  30498. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  30499. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  30500. $this->ensureDirectoryExists($target);
  30501. $result = true;
  30502. foreach ($ri as $file) {
  30503. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  30504. if ($file->isDir()) {
  30505. $this->ensureDirectoryExists($targetPath);
  30506. } else {
  30507. $result = $result && copy($file->getPathname(), $targetPath);
  30508. }
  30509. }
  30510. return $result;
  30511. }
  30512. public function rename($source, $target)
  30513. {
  30514. if (true === @rename($source, $target)) {
  30515. return;
  30516. }
  30517. if (!\function_exists('proc_open')) {
  30518. $this->copyThenRemove($source, $target);
  30519. return;
  30520. }
  30521. if (Platform::isWindows()) {
  30522. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  30523. $result = $this->getProcess()->execute($command, $output);
  30524. clearstatcache();
  30525. if (0 === $result) {
  30526. $this->remove($source);
  30527. return;
  30528. }
  30529. } else {
  30530. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  30531. $result = $this->getProcess()->execute($command, $output);
  30532. clearstatcache();
  30533. if (0 === $result) {
  30534. return;
  30535. }
  30536. }
  30537. $this->copyThenRemove($source, $target);
  30538. }
  30539. public function findShortestPath($from, $to, $directories = false)
  30540. {
  30541. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  30542. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  30543. }
  30544. $from = lcfirst($this->normalizePath($from));
  30545. $to = lcfirst($this->normalizePath($to));
  30546. if ($directories) {
  30547. $from = rtrim($from, '/') . '/dummy_file';
  30548. }
  30549. if (\dirname($from) === \dirname($to)) {
  30550. return './'.basename($to);
  30551. }
  30552. $commonPath = $to;
  30553. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath)) {
  30554. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  30555. }
  30556. if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
  30557. return $to;
  30558. }
  30559. $commonPath = rtrim($commonPath, '/') . '/';
  30560. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/');
  30561. $commonPathCode = str_repeat('../', $sourcePathDepth);
  30562. return ($commonPathCode . substr($to, \strlen($commonPath))) ?: './';
  30563. }
  30564. public function findShortestPathCode($from, $to, $directories = false, $staticCode = false)
  30565. {
  30566. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  30567. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  30568. }
  30569. $from = lcfirst($this->normalizePath($from));
  30570. $to = lcfirst($this->normalizePath($to));
  30571. if ($from === $to) {
  30572. return $directories ? '__DIR__' : '__FILE__';
  30573. }
  30574. $commonPath = $to;
  30575. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  30576. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  30577. }
  30578. if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
  30579. return var_export($to, true);
  30580. }
  30581. $commonPath = rtrim($commonPath, '/') . '/';
  30582. if (strpos($to, $from.'/') === 0) {
  30583. return '__DIR__ . '.var_export(substr($to, \strlen($from)), true);
  30584. }
  30585. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/') + $directories;
  30586. if ($staticCode) {
  30587. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  30588. } else {
  30589. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  30590. }
  30591. $relTarget = substr($to, \strlen($commonPath));
  30592. return $commonPathCode . (\strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
  30593. }
  30594. public function isAbsolutePath($path)
  30595. {
  30596. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  30597. }
  30598. public function size($path)
  30599. {
  30600. if (!file_exists($path)) {
  30601. throw new \RuntimeException("$path does not exist.");
  30602. }
  30603. if (is_dir($path)) {
  30604. return $this->directorySize($path);
  30605. }
  30606. return filesize($path);
  30607. }
  30608. public function normalizePath($path)
  30609. {
  30610. $parts = array();
  30611. $path = strtr($path, '\\', '/');
  30612. $prefix = '';
  30613. $absolute = '';
  30614. if (strpos($path, '//') === 0 && \strlen($path) > 2) {
  30615. $absolute = '//';
  30616. $path = substr($path, 2);
  30617. }
  30618. if (preg_match('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  30619. $prefix = $match[1];
  30620. $path = substr($path, \strlen($prefix));
  30621. }
  30622. if (strpos($path, '/') === 0) {
  30623. $absolute = '/';
  30624. $path = substr($path, 1);
  30625. }
  30626. $up = false;
  30627. foreach (explode('/', $path) as $chunk) {
  30628. if ('..' === $chunk && ($absolute !== '' || $up)) {
  30629. array_pop($parts);
  30630. $up = !(empty($parts) || '..' === end($parts));
  30631. } elseif ('.' !== $chunk && '' !== $chunk) {
  30632. $parts[] = $chunk;
  30633. $up = '..' !== $chunk;
  30634. }
  30635. }
  30636. return $prefix.((string) $absolute).implode('/', $parts);
  30637. }
  30638. public static function trimTrailingSlash($path)
  30639. {
  30640. if (!preg_match('{^[/\\\\]+$}', $path)) {
  30641. $path = rtrim($path, '/\\');
  30642. }
  30643. return $path;
  30644. }
  30645. public static function isLocalPath($path)
  30646. {
  30647. return (bool) preg_match('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  30648. }
  30649. public static function getPlatformPath($path)
  30650. {
  30651. if (Platform::isWindows()) {
  30652. $path = preg_replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  30653. }
  30654. return (string) preg_replace('{^file://}i', '', $path);
  30655. }
  30656. public static function isReadable($path)
  30657. {
  30658. if (is_readable($path)) {
  30659. return true;
  30660. }
  30661. if (is_file($path)) {
  30662. return false !== Silencer::call('file_get_contents', $path, false, null, 0, 1);
  30663. }
  30664. if (is_dir($path)) {
  30665. return false !== Silencer::call('opendir', $path);
  30666. }
  30667. return false;
  30668. }
  30669. protected function directorySize($directory)
  30670. {
  30671. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  30672. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  30673. $size = 0;
  30674. foreach ($ri as $file) {
  30675. if ($file->isFile()) {
  30676. $size += $file->getSize();
  30677. }
  30678. }
  30679. return $size;
  30680. }
  30681. protected function getProcess()
  30682. {
  30683. if (!$this->processExecutor) {
  30684. $this->processExecutor = new ProcessExecutor();
  30685. }
  30686. return $this->processExecutor;
  30687. }
  30688. private function unlinkImplementation($path)
  30689. {
  30690. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  30691. return rmdir($path);
  30692. }
  30693. return unlink($path);
  30694. }
  30695. public function relativeSymlink($target, $link)
  30696. {
  30697. if (!function_exists('symlink')) {
  30698. return false;
  30699. }
  30700. $cwd = getcwd();
  30701. $relativePath = $this->findShortestPath($link, $target);
  30702. chdir(\dirname($link));
  30703. $result = @symlink($relativePath, $link);
  30704. chdir($cwd);
  30705. return $result;
  30706. }
  30707. public function isSymlinkedDirectory($directory)
  30708. {
  30709. if (!is_dir($directory)) {
  30710. return false;
  30711. }
  30712. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  30713. return is_link($resolved);
  30714. }
  30715. private function unlinkSymlinkedDirectory($directory)
  30716. {
  30717. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  30718. return $this->unlink($resolved);
  30719. }
  30720. private function resolveSymlinkedDirectorySymlink($pathname)
  30721. {
  30722. if (!is_dir($pathname)) {
  30723. return $pathname;
  30724. }
  30725. $resolved = rtrim($pathname, '/');
  30726. if (!\strlen($resolved)) {
  30727. return $pathname;
  30728. }
  30729. return $resolved;
  30730. }
  30731. public function junction($target, $junction)
  30732. {
  30733. if (!Platform::isWindows()) {
  30734. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  30735. }
  30736. if (!is_dir($target)) {
  30737. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  30738. }
  30739. $cmd = sprintf(
  30740. 'mklink /J %s %s',
  30741. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  30742. ProcessExecutor::escape(realpath($target))
  30743. );
  30744. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  30745. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  30746. }
  30747. clearstatcache(true, $junction);
  30748. }
  30749. public function isJunction($junction)
  30750. {
  30751. if (!Platform::isWindows()) {
  30752. return false;
  30753. }
  30754. clearstatcache(true, $junction);
  30755. if (!is_dir($junction) || is_link($junction)) {
  30756. return false;
  30757. }
  30758. $stat = lstat($junction);
  30759. return $stat ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  30760. }
  30761. public function removeJunction($junction)
  30762. {
  30763. if (!Platform::isWindows()) {
  30764. return false;
  30765. }
  30766. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  30767. if (!$this->isJunction($junction)) {
  30768. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  30769. }
  30770. return $this->rmdir($junction);
  30771. }
  30772. public function filePutContentsIfModified($path, $content)
  30773. {
  30774. $currentContent = @file_get_contents($path);
  30775. if (!$currentContent || ($currentContent != $content)) {
  30776. return file_put_contents($path, $content);
  30777. }
  30778. return 0;
  30779. }
  30780. public function safeCopy($source, $target)
  30781. {
  30782. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  30783. $source = fopen($source, 'r');
  30784. $target = fopen($target, 'w+');
  30785. stream_copy_to_stream($source, $target);
  30786. fclose($source);
  30787. fclose($target);
  30788. }
  30789. }
  30790. private function filesAreEqual($a, $b)
  30791. {
  30792. if (filesize($a) !== filesize($b)) {
  30793. return false;
  30794. }
  30795. $ah = fopen($a, 'rb');
  30796. $bh = fopen($b, 'rb');
  30797. $result = true;
  30798. while (!feof($ah)) {
  30799. if (fread($ah, 8192) != fread($bh, 8192)) {
  30800. $result = false;
  30801. break;
  30802. }
  30803. }
  30804. fclose($ah);
  30805. fclose($bh);
  30806. return $result;
  30807. }
  30808. }
  30809. <?php
  30810. namespace Composer\Util;
  30811. use Composer\Config;
  30812. use Composer\IO\IOInterface;
  30813. class Git
  30814. {
  30815. private static $version = false;
  30816. protected $io;
  30817. protected $config;
  30818. protected $process;
  30819. protected $filesystem;
  30820. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  30821. {
  30822. $this->io = $io;
  30823. $this->config = $config;
  30824. $this->process = $process;
  30825. $this->filesystem = $fs;
  30826. }
  30827. public function runCommand($commandCallable, $url, $cwd, $initialClone = false)
  30828. {
  30829. $this->config->prohibitUrlByConfig($url, $this->io);
  30830. if ($initialClone) {
  30831. $origCwd = $cwd;
  30832. $cwd = null;
  30833. }
  30834. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  30835. 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.');
  30836. }
  30837. if (!$initialClone) {
  30838. $this->process->execute('git remote -v', $output, $cwd);
  30839. if (preg_match('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  30840. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  30841. }
  30842. }
  30843. $protocols = $this->config->get('github-protocols');
  30844. if (!is_array($protocols)) {
  30845. throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
  30846. }
  30847. if (preg_match('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  30848. $messages = array();
  30849. foreach ($protocols as $protocol) {
  30850. if ('ssh' === $protocol) {
  30851. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  30852. } else {
  30853. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  30854. }
  30855. if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $ignoredOutput, $cwd)) {
  30856. return;
  30857. }
  30858. $messages[] = '- ' . $protoUrl . "\n" . preg_replace('#^#m', ' ', $this->process->getErrorOutput());
  30859. if ($initialClone && isset($origCwd)) {
  30860. $this->filesystem->removeDirectory($origCwd);
  30861. }
  30862. }
  30863. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  30864. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  30865. }
  30866. }
  30867. $bypassSshForGitHub = preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  30868. $command = call_user_func($commandCallable, $url);
  30869. $auth = null;
  30870. $credentials = array();
  30871. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
  30872. $errorMsg = $this->process->getErrorOutput();
  30873. if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  30874. || preg_match('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*?)(?:\.git)?$}i', $url, $match)
  30875. ) {
  30876. if (!$this->io->hasAuthentication($match[1])) {
  30877. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  30878. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  30879. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  30880. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  30881. }
  30882. }
  30883. if ($this->io->hasAuthentication($match[1])) {
  30884. $auth = $this->io->getAuthentication($match[1]);
  30885. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  30886. $command = call_user_func($commandCallable, $authUrl);
  30887. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  30888. return;
  30889. }
  30890. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  30891. $errorMsg = $this->process->getErrorOutput();
  30892. }
  30893. } elseif (preg_match('{^https://(bitbucket\.org)/(.*?)(?:\.git)?$}i', $url, $match)) {
  30894. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  30895. if (!$this->io->hasAuthentication($match[1])) {
  30896. $message = 'Enter your Bitbucket credentials to access private repos';
  30897. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  30898. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  30899. $accessToken = $bitbucketUtil->getToken();
  30900. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  30901. }
  30902. } else {
  30903. $auth = $this->io->getAuthentication($match[1]);
  30904. if ($auth['username'] !== 'x-token-auth') {
  30905. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  30906. if (!empty($accessToken)) {
  30907. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  30908. }
  30909. }
  30910. }
  30911. if ($this->io->hasAuthentication($match[1])) {
  30912. $auth = $this->io->getAuthentication($match[1]);
  30913. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  30914. $command = call_user_func($commandCallable, $authUrl);
  30915. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  30916. return;
  30917. }
  30918. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  30919. $errorMsg = $this->process->getErrorOutput();
  30920. } else {
  30921. $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git';
  30922. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  30923. $command = call_user_func($commandCallable, $sshUrl);
  30924. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  30925. return;
  30926. }
  30927. $errorMsg = $this->process->getErrorOutput();
  30928. }
  30929. } elseif (
  30930. preg_match('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  30931. || preg_match('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}i', $url, $match)
  30932. ) {
  30933. if ($match[1] === 'git') {
  30934. $match[1] = 'https';
  30935. }
  30936. if (!$this->io->hasAuthentication($match[2])) {
  30937. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  30938. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  30939. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  30940. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  30941. }
  30942. }
  30943. if ($this->io->hasAuthentication($match[2])) {
  30944. $auth = $this->io->getAuthentication($match[2]);
  30945. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  30946. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode($auth['username']) . '@' . $match[2] . '/' . $match[3];
  30947. } else {
  30948. $authUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . '/' . $match[3];
  30949. }
  30950. $command = call_user_func($commandCallable, $authUrl);
  30951. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  30952. return;
  30953. }
  30954. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  30955. $errorMsg = $this->process->getErrorOutput();
  30956. }
  30957. } elseif ($this->isAuthenticationFailure($url, $match)) {
  30958. if (strpos($match[2], '@')) {
  30959. list($authParts, $match[2]) = explode('@', $match[2], 2);
  30960. }
  30961. $storeAuth = false;
  30962. if ($this->io->hasAuthentication($match[2])) {
  30963. $auth = $this->io->getAuthentication($match[2]);
  30964. } elseif ($this->io->isInteractive()) {
  30965. $defaultUsername = null;
  30966. if (isset($authParts) && $authParts) {
  30967. if (false !== strpos($authParts, ':')) {
  30968. list($defaultUsername, ) = explode(':', $authParts, 2);
  30969. } else {
  30970. $defaultUsername = $authParts;
  30971. }
  30972. }
  30973. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  30974. $auth = array(
  30975. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  30976. 'password' => $this->io->askAndHideAnswer(' Password: '),
  30977. );
  30978. $storeAuth = $this->config->get('store-auths');
  30979. }
  30980. if ($auth) {
  30981. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  30982. $command = call_user_func($commandCallable, $authUrl);
  30983. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  30984. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  30985. $authHelper = new AuthHelper($this->io, $this->config);
  30986. $authHelper->storeAuth($match[2], $storeAuth);
  30987. return;
  30988. }
  30989. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  30990. $errorMsg = $this->process->getErrorOutput();
  30991. }
  30992. }
  30993. if ($initialClone && isset($origCwd)) {
  30994. $this->filesystem->removeDirectory($origCwd);
  30995. }
  30996. if (count($credentials) > 0) {
  30997. $command = $this->maskCredentials($command, $credentials);
  30998. $errorMsg = $this->maskCredentials($errorMsg, $credentials);
  30999. }
  31000. $this->throwException('Failed to execute ' . $command . "\n\n" . $errorMsg, $url);
  31001. }
  31002. }
  31003. public function syncMirror($url, $dir)
  31004. {
  31005. if (getenv('COMPOSER_DISABLE_NETWORK') && getenv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  31006. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  31007. return false;
  31008. }
  31009. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  31010. try {
  31011. $commandCallable = function ($url) {
  31012. $sanitizedUrl = preg_replace('{://([^@]+?):(.+?)@}', '://', $url);
  31013. return sprintf('git remote set-url origin -- %s && git remote update --prune origin && git remote set-url origin -- %s && git gc --auto', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl));
  31014. };
  31015. $this->runCommand($commandCallable, $url, $dir);
  31016. } catch (\Exception $e) {
  31017. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  31018. return false;
  31019. }
  31020. return true;
  31021. }
  31022. $this->filesystem->removeDirectory($dir);
  31023. $commandCallable = function ($url) use ($dir) {
  31024. return sprintf('git clone --mirror -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  31025. };
  31026. $this->runCommand($commandCallable, $url, $dir, true);
  31027. return true;
  31028. }
  31029. public function fetchRefOrSyncMirror($url, $dir, $ref)
  31030. {
  31031. if ($this->checkRefIsInMirror($dir, $ref)) {
  31032. return true;
  31033. }
  31034. if ($this->syncMirror($url, $dir)) {
  31035. return $this->checkRefIsInMirror($dir, $ref);
  31036. }
  31037. return false;
  31038. }
  31039. public static function getNoShowSignatureFlag(ProcessExecutor $process)
  31040. {
  31041. $gitVersion = self::getVersion($process);
  31042. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  31043. return ' --no-show-signature';
  31044. }
  31045. return '';
  31046. }
  31047. private function checkRefIsInMirror($dir, $ref)
  31048. {
  31049. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  31050. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  31051. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $ignoredOutput, $dir);
  31052. if ($exitCode === 0) {
  31053. return true;
  31054. }
  31055. }
  31056. return false;
  31057. }
  31058. private function isAuthenticationFailure($url, &$match)
  31059. {
  31060. if (!preg_match('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  31061. return false;
  31062. }
  31063. $authFailures = array(
  31064. 'fatal: Authentication failed',
  31065. 'remote error: Invalid username or password.',
  31066. 'error: 401 Unauthorized',
  31067. 'fatal: unable to access',
  31068. 'fatal: could not read Username',
  31069. );
  31070. $errorOutput = $this->process->getErrorOutput();
  31071. foreach ($authFailures as $authFailure) {
  31072. if (strpos($errorOutput, $authFailure) !== false) {
  31073. return true;
  31074. }
  31075. }
  31076. return false;
  31077. }
  31078. public static function cleanEnv()
  31079. {
  31080. if (PHP_VERSION_ID < 50400 && ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {
  31081. 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');
  31082. }
  31083. if (getenv('GIT_ASKPASS') !== 'echo') {
  31084. Platform::putEnv('GIT_ASKPASS', 'echo');
  31085. }
  31086. if (getenv('GIT_DIR')) {
  31087. Platform::clearEnv('GIT_DIR');
  31088. }
  31089. if (getenv('GIT_WORK_TREE')) {
  31090. Platform::clearEnv('GIT_WORK_TREE');
  31091. }
  31092. if (getenv('LANGUAGE') !== 'C') {
  31093. Platform::putEnv('LANGUAGE', 'C');
  31094. }
  31095. Platform::clearEnv('DYLD_LIBRARY_PATH');
  31096. }
  31097. public static function getGitHubDomainsRegex(Config $config)
  31098. {
  31099. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  31100. }
  31101. public static function getGitLabDomainsRegex(Config $config)
  31102. {
  31103. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  31104. }
  31105. private function throwException($message, $url)
  31106. {
  31107. clearstatcache();
  31108. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  31109. 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()));
  31110. }
  31111. throw new \RuntimeException(Url::sanitize($message));
  31112. }
  31113. public static function getVersion(ProcessExecutor $process)
  31114. {
  31115. if (false === self::$version) {
  31116. self::$version = null;
  31117. if (0 === $process->execute('git --version', $output) && preg_match('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  31118. self::$version = $matches[1];
  31119. }
  31120. }
  31121. return self::$version;
  31122. }
  31123. private function maskCredentials($error, array $credentials)
  31124. {
  31125. $maskedCredentials = array();
  31126. foreach ($credentials as $credential) {
  31127. if (in_array($credential, array('private-token', 'x-token-auth', 'oauth2', 'gitlab-ci-token', 'x-oauth-basic'))) {
  31128. $maskedCredentials[] = $credential;
  31129. } elseif (strlen($credential) > 6) {
  31130. $maskedCredentials[] = substr($credential, 0, 3) . '...' . substr($credential, -3);
  31131. } elseif (strlen($credential) > 3) {
  31132. $maskedCredentials[] = substr($credential, 0, 3) . '...';
  31133. } else {
  31134. $maskedCredentials[] = 'XXX';
  31135. }
  31136. }
  31137. return str_replace($credentials, $maskedCredentials, $error);
  31138. }
  31139. }
  31140. <?php
  31141. namespace Composer\Util;
  31142. use Composer\Factory;
  31143. use Composer\IO\IOInterface;
  31144. use Composer\Config;
  31145. use Composer\Downloader\TransportException;
  31146. class GitHub
  31147. {
  31148. protected $io;
  31149. protected $config;
  31150. protected $process;
  31151. protected $httpDownloader;
  31152. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  31153. {
  31154. $this->io = $io;
  31155. $this->config = $config;
  31156. $this->process = $process ?: new ProcessExecutor($io);
  31157. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  31158. }
  31159. public function authorizeOAuth($originUrl)
  31160. {
  31161. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  31162. return false;
  31163. }
  31164. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  31165. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  31166. return true;
  31167. }
  31168. return false;
  31169. }
  31170. public function authorizeOAuthInteractively($originUrl, $message = null)
  31171. {
  31172. if ($message) {
  31173. $this->io->writeError($message);
  31174. }
  31175. $note = 'Composer';
  31176. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  31177. $note .= ' on ' . trim($output);
  31178. }
  31179. $note .= ' ' . date('Y-m-d Hi');
  31180. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=&description=' . str_replace('%20', '+', rawurlencode($note));
  31181. $this->io->writeError(sprintf('When working with _public_ GitHub repositories only, head to %s to retrieve a token.', $url));
  31182. $this->io->writeError('This token will have read-only permission for public information only.');
  31183. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  31184. $this->io->writeError(sprintf('When you need to access _private_ GitHub repositories as well, go to %s', $url));
  31185. $this->io->writeError('Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.');
  31186. $this->io->writeError(sprintf('Tokens will be stored in plain text in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  31187. $this->io->writeError('For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth');
  31188. $token = trim($this->io->askAndHideAnswer('Token (hidden): '));
  31189. if (!$token) {
  31190. $this->io->writeError('<warning>No token given, aborting.</warning>');
  31191. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  31192. return false;
  31193. }
  31194. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  31195. try {
  31196. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  31197. $this->httpDownloader->get('https://'. $apiUrl, array(
  31198. 'retry-auth-failure' => false,
  31199. ));
  31200. } catch (TransportException $e) {
  31201. if (in_array($e->getCode(), array(403, 401))) {
  31202. $this->io->writeError('<error>Invalid token provided.</error>');
  31203. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  31204. return false;
  31205. }
  31206. throw $e;
  31207. }
  31208. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  31209. $this->config->getAuthConfigSource()->addConfigSetting('github-oauth.'.$originUrl, $token);
  31210. $this->io->writeError('<info>Token stored successfully.</info>');
  31211. return true;
  31212. }
  31213. public function getRateLimit(array $headers)
  31214. {
  31215. $rateLimit = array(
  31216. 'limit' => '?',
  31217. 'reset' => '?',
  31218. );
  31219. foreach ($headers as $header) {
  31220. $header = trim($header);
  31221. if (false === strpos($header, 'X-RateLimit-')) {
  31222. continue;
  31223. }
  31224. list($type, $value) = explode(':', $header, 2);
  31225. switch ($type) {
  31226. case 'X-RateLimit-Limit':
  31227. $rateLimit['limit'] = (int) trim($value);
  31228. break;
  31229. case 'X-RateLimit-Reset':
  31230. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  31231. break;
  31232. }
  31233. }
  31234. return $rateLimit;
  31235. }
  31236. public function isRateLimited(array $headers)
  31237. {
  31238. foreach ($headers as $header) {
  31239. if (preg_match('{^X-RateLimit-Remaining: *0$}i', trim($header))) {
  31240. return true;
  31241. }
  31242. }
  31243. return false;
  31244. }
  31245. }
  31246. <?php
  31247. namespace Composer\Util;
  31248. use Composer\IO\IOInterface;
  31249. use Composer\Config;
  31250. use Composer\Factory;
  31251. use Composer\Downloader\TransportException;
  31252. class GitLab
  31253. {
  31254. protected $io;
  31255. protected $config;
  31256. protected $process;
  31257. protected $httpDownloader;
  31258. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  31259. {
  31260. $this->io = $io;
  31261. $this->config = $config;
  31262. $this->process = $process ?: new ProcessExecutor($io);
  31263. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  31264. }
  31265. public function authorizeOAuth($originUrl)
  31266. {
  31267. $bcOriginUrl = preg_replace('{:\d+}', '', $originUrl);
  31268. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  31269. return false;
  31270. }
  31271. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  31272. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  31273. return true;
  31274. }
  31275. if (0 === $this->process->execute('git config gitlab.deploytoken.user', $tokenUser) && 0 === $this->process->execute('git config gitlab.deploytoken.token', $tokenPassword)) {
  31276. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  31277. return true;
  31278. }
  31279. $authTokens = $this->config->get('gitlab-token');
  31280. if (isset($authTokens[$originUrl])) {
  31281. $token = $authTokens[$originUrl];
  31282. }
  31283. if (isset($authTokens[$bcOriginUrl])) {
  31284. $token = $authTokens[$bcOriginUrl];
  31285. }
  31286. if (isset($token)) {
  31287. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  31288. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  31289. $this->io->setAuthentication($originUrl, $username, $password);
  31290. return true;
  31291. }
  31292. return false;
  31293. }
  31294. public function authorizeOAuthInteractively($scheme, $originUrl, $message = null)
  31295. {
  31296. if ($message) {
  31297. $this->io->writeError($message);
  31298. }
  31299. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
  31300. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/-/profile/personal_access_tokens');
  31301. $attemptCounter = 0;
  31302. while ($attemptCounter++ < 5) {
  31303. try {
  31304. $response = $this->createToken($scheme, $originUrl);
  31305. } catch (TransportException $e) {
  31306. if (in_array($e->getCode(), array(403, 401))) {
  31307. if (401 === $e->getCode()) {
  31308. $response = json_decode($e->getResponse(), true);
  31309. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  31310. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  31311. } else {
  31312. $this->io->writeError('Bad credentials.');
  31313. }
  31314. } else {
  31315. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  31316. }
  31317. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  31318. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  31319. continue;
  31320. }
  31321. throw $e;
  31322. }
  31323. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  31324. $this->config->getAuthConfigSource()->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  31325. return true;
  31326. }
  31327. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  31328. }
  31329. private function createToken($scheme, $originUrl)
  31330. {
  31331. $username = $this->io->ask('Username: ');
  31332. $password = $this->io->askAndHideAnswer('Password: ');
  31333. $headers = array('Content-Type: application/x-www-form-urlencoded');
  31334. $apiUrl = $originUrl;
  31335. $data = http_build_query(array(
  31336. 'username' => $username,
  31337. 'password' => $password,
  31338. 'grant_type' => 'password',
  31339. ), '', '&');
  31340. $options = array(
  31341. 'retry-auth-failure' => false,
  31342. 'http' => array(
  31343. 'method' => 'POST',
  31344. 'header' => $headers,
  31345. 'content' => $data,
  31346. ),
  31347. );
  31348. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  31349. $this->io->writeError('Token successfully created');
  31350. return $token;
  31351. }
  31352. }
  31353. <?php
  31354. namespace Composer\Util;
  31355. use Composer\Config;
  31356. use Composer\IO\IOInterface;
  31357. class Hg
  31358. {
  31359. private static $version = false;
  31360. private $io;
  31361. private $config;
  31362. private $process;
  31363. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  31364. {
  31365. $this->io = $io;
  31366. $this->config = $config;
  31367. $this->process = $process;
  31368. }
  31369. public function runCommand($commandCallable, $url, $cwd)
  31370. {
  31371. $this->config->prohibitUrlByConfig($url, $this->io);
  31372. $command = call_user_func($commandCallable, $url);
  31373. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  31374. return;
  31375. }
  31376. if (preg_match('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) {
  31377. $auth = $this->io->getAuthentication($match[5]);
  31378. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null);
  31379. $command = call_user_func($commandCallable, $authenticatedUrl);
  31380. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  31381. return;
  31382. }
  31383. $error = $this->process->getErrorOutput();
  31384. } else {
  31385. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  31386. }
  31387. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  31388. }
  31389. private function throwException($message, $url)
  31390. {
  31391. if (null === self::getVersion($this->process)) {
  31392. 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()));
  31393. }
  31394. throw new \RuntimeException(Url::sanitize($message));
  31395. }
  31396. public static function getVersion(ProcessExecutor $process)
  31397. {
  31398. if (false === self::$version) {
  31399. self::$version = null;
  31400. if (0 === $process->execute('hg --version', $output) && preg_match('/^.+? (\d+(?:\.\d+)+)\)?\r?\n/', $output, $matches)) {
  31401. self::$version = $matches[1];
  31402. }
  31403. }
  31404. return self::$version;
  31405. }
  31406. }
  31407. <?php
  31408. namespace Composer\Util\Http;
  31409. use Composer\Config;
  31410. use Composer\Downloader\MaxFileSizeExceededException;
  31411. use Composer\IO\IOInterface;
  31412. use Composer\Downloader\TransportException;
  31413. use Composer\Util\StreamContextFactory;
  31414. use Composer\Util\AuthHelper;
  31415. use Composer\Util\Url;
  31416. use Composer\Util\HttpDownloader;
  31417. use React\Promise\Promise;
  31418. class CurlDownloader
  31419. {
  31420. private $multiHandle;
  31421. private $shareHandle;
  31422. private $jobs = array();
  31423. private $io;
  31424. private $config;
  31425. private $authHelper;
  31426. private $selectTimeout = 5.0;
  31427. private $maxRedirects = 20;
  31428. private $proxyManager;
  31429. private $supportsSecureProxy;
  31430. protected $multiErrors = array(
  31431. CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'),
  31432. 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."),
  31433. CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'),
  31434. CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'),
  31435. );
  31436. private static $options = array(
  31437. 'http' => array(
  31438. 'method' => CURLOPT_CUSTOMREQUEST,
  31439. 'content' => CURLOPT_POSTFIELDS,
  31440. 'header' => CURLOPT_HTTPHEADER,
  31441. 'timeout' => CURLOPT_TIMEOUT,
  31442. ),
  31443. 'ssl' => array(
  31444. 'cafile' => CURLOPT_CAINFO,
  31445. 'capath' => CURLOPT_CAPATH,
  31446. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  31447. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  31448. 'local_cert' => CURLOPT_SSLCERT,
  31449. 'local_pk' => CURLOPT_SSLKEY,
  31450. 'passphrase' => CURLOPT_SSLKEYPASSWD,
  31451. ),
  31452. );
  31453. private static $timeInfo = array(
  31454. 'total_time' => true,
  31455. 'namelookup_time' => true,
  31456. 'connect_time' => true,
  31457. 'pretransfer_time' => true,
  31458. 'starttransfer_time' => true,
  31459. 'redirect_time' => true,
  31460. );
  31461. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  31462. {
  31463. $this->io = $io;
  31464. $this->config = $config;
  31465. $this->multiHandle = $mh = curl_multi_init();
  31466. if (function_exists('curl_multi_setopt')) {
  31467. curl_multi_setopt($mh, CURLMOPT_PIPELINING, PHP_VERSION_ID >= 70400 ? 2 : 3);
  31468. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  31469. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  31470. }
  31471. }
  31472. if (function_exists('curl_share_init')) {
  31473. $this->shareHandle = $sh = curl_share_init();
  31474. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  31475. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  31476. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  31477. }
  31478. $this->authHelper = new AuthHelper($io, $config);
  31479. $this->proxyManager = ProxyManager::getInstance();
  31480. $version = curl_version();
  31481. $features = $version['features'];
  31482. $this->supportsSecureProxy = defined('CURL_VERSION_HTTPS_PROXY') && ($features & CURL_VERSION_HTTPS_PROXY);
  31483. }
  31484. public function download($resolve, $reject, $origin, $url, $options, $copyTo = null)
  31485. {
  31486. $attributes = array();
  31487. if (isset($options['retry-auth-failure'])) {
  31488. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  31489. unset($options['retry-auth-failure']);
  31490. }
  31491. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  31492. }
  31493. private function initDownload($resolve, $reject, $origin, $url, $options, $copyTo = null, array $attributes = array())
  31494. {
  31495. $attributes = array_merge(array(
  31496. 'retryAuthFailure' => true,
  31497. 'redirects' => 0,
  31498. 'storeAuth' => false,
  31499. ), $attributes);
  31500. $originalOptions = $options;
  31501. if (!preg_match('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  31502. $this->config->prohibitUrlByConfig($url, $this->io);
  31503. }
  31504. $curlHandle = curl_init();
  31505. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  31506. if ($copyTo) {
  31507. $errorMessage = '';
  31508. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  31509. if ($errorMessage) {
  31510. $errorMessage .= "\n";
  31511. }
  31512. $errorMessage .= preg_replace('{^fopen\(.*?\): }', '', $msg);
  31513. });
  31514. $bodyHandle = fopen($copyTo.'~', 'w+b');
  31515. restore_error_handler();
  31516. if (!$bodyHandle) {
  31517. throw new TransportException('The "'.$url.'" file could not be written to '.$copyTo.': '.$errorMessage);
  31518. }
  31519. } else {
  31520. $bodyHandle = @fopen('php://temp/maxmemory:524288', 'w+b');
  31521. }
  31522. curl_setopt($curlHandle, CURLOPT_URL, $url);
  31523. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  31524. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  31525. curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));
  31526. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  31527. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  31528. curl_setopt($curlHandle, CURLOPT_ENCODING, "");
  31529. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
  31530. if (function_exists('curl_share_init')) {
  31531. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  31532. }
  31533. if (!isset($options['http']['header'])) {
  31534. $options['http']['header'] = array();
  31535. }
  31536. $options['http']['header'] = array_diff($options['http']['header'], array('Connection: close'));
  31537. $options['http']['header'][] = 'Connection: keep-alive';
  31538. $version = curl_version();
  31539. $features = $version['features'];
  31540. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {
  31541. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  31542. }
  31543. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  31544. $options = StreamContextFactory::initOptions($url, $options, true);
  31545. foreach (self::$options as $type => $curlOptions) {
  31546. foreach ($curlOptions as $name => $curlOption) {
  31547. if (isset($options[$type][$name])) {
  31548. if ($type === 'ssl' && $name === 'verify_peer_name') {
  31549. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  31550. } else {
  31551. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  31552. }
  31553. }
  31554. }
  31555. }
  31556. $proxy = $this->proxyManager->getProxyForRequest($url);
  31557. curl_setopt($curlHandle, CURLOPT_PROXY, $proxy->getUrl());
  31558. if ($proxy->isSecure()) {
  31559. if (!$this->supportsSecureProxy) {
  31560. throw new TransportException('Connecting to a secure proxy using curl is not supported on PHP versions below 7.3.0.');
  31561. }
  31562. if (!empty($options['ssl']['cafile'])) {
  31563. curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);
  31564. }
  31565. if (!empty($options['ssl']['capath'])) {
  31566. curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);
  31567. }
  31568. }
  31569. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  31570. $this->jobs[(int) $curlHandle] = array(
  31571. 'url' => $url,
  31572. 'origin' => $origin,
  31573. 'attributes' => $attributes,
  31574. 'options' => $originalOptions,
  31575. 'progress' => $progress,
  31576. 'curlHandle' => $curlHandle,
  31577. 'filename' => $copyTo,
  31578. 'headerHandle' => $headerHandle,
  31579. 'bodyHandle' => $bodyHandle,
  31580. 'resolve' => $resolve,
  31581. 'reject' => $reject,
  31582. );
  31583. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  31584. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  31585. if ($attributes['redirects'] === 0) {
  31586. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  31587. }
  31588. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  31589. return (int) $curlHandle;
  31590. }
  31591. public function abortRequest($id)
  31592. {
  31593. if (isset($this->jobs[$id], $this->jobs[$id]['handle'])) {
  31594. $job = $this->jobs[$id];
  31595. curl_multi_remove_handle($this->multiHandle, $job['handle']);
  31596. curl_close($job['handle']);
  31597. if (is_resource($job['headerHandle'])) {
  31598. fclose($job['headerHandle']);
  31599. }
  31600. if (is_resource($job['bodyHandle'])) {
  31601. fclose($job['bodyHandle']);
  31602. }
  31603. if ($job['filename']) {
  31604. @unlink($job['filename'].'~');
  31605. }
  31606. unset($this->jobs[$id]);
  31607. }
  31608. }
  31609. public function tick()
  31610. {
  31611. static $timeoutWarning = false;
  31612. if (!$this->jobs) {
  31613. return;
  31614. }
  31615. $active = true;
  31616. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  31617. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  31618. usleep(150);
  31619. }
  31620. while ($progress = curl_multi_info_read($this->multiHandle)) {
  31621. $curlHandle = $progress['handle'];
  31622. $result = $progress['result'];
  31623. $i = (int) $curlHandle;
  31624. if (!isset($this->jobs[$i])) {
  31625. continue;
  31626. }
  31627. $progress = curl_getinfo($curlHandle);
  31628. $job = $this->jobs[$i];
  31629. unset($this->jobs[$i]);
  31630. $error = curl_error($curlHandle);
  31631. $errno = curl_errno($curlHandle);
  31632. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  31633. curl_close($curlHandle);
  31634. $headers = null;
  31635. $statusCode = null;
  31636. $response = null;
  31637. try {
  31638. if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) {
  31639. $errno = $errno ?: $result;
  31640. if (!$error && function_exists('curl_strerror')) {
  31641. $error = curl_strerror($errno);
  31642. }
  31643. $progress['error_code'] = $errno;
  31644. if ($errno === 28 && isset($progress['namelookup_time']) && $progress['namelookup_time'] == 0 && !$timeoutWarning) {
  31645. $timeoutWarning = true;
  31646. $this->io->writeError('<warning>A connection timeout was encountered. If you intend to run Composer without connecting to the internet, run the command again prefixed with COMPOSER_DISABLE_NETWORK=1 to make Composer run in offline mode.</warning>');
  31647. }
  31648. throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
  31649. }
  31650. $statusCode = $progress['http_code'];
  31651. rewind($job['headerHandle']);
  31652. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  31653. fclose($job['headerHandle']);
  31654. if ($statusCode === 0) {
  31655. throw new \LogicException('Received unexpected http status code 0 without error for '.Url::sanitize($progress['url']).': headers '.var_export($headers, true).' curl info '.var_export($progress, true));
  31656. }
  31657. if ($job['filename']) {
  31658. $contents = $job['filename'].'~';
  31659. if ($statusCode >= 300) {
  31660. rewind($job['bodyHandle']);
  31661. $contents = stream_get_contents($job['bodyHandle']);
  31662. }
  31663. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  31664. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  31665. } else {
  31666. rewind($job['bodyHandle']);
  31667. $contents = stream_get_contents($job['bodyHandle']);
  31668. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  31669. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  31670. }
  31671. fclose($job['bodyHandle']);
  31672. if ($response->getStatusCode() >= 400 && $response->getHeader('content-type') === 'application/json') {
  31673. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  31674. }
  31675. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  31676. if ($result['retry']) {
  31677. $this->restartJob($job, $job['url'], array('storeAuth' => $result['storeAuth']));
  31678. continue;
  31679. }
  31680. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  31681. $location = $this->handleRedirect($job, $response);
  31682. if ($location) {
  31683. $this->restartJob($job, $location, array('redirects' => $job['attributes']['redirects'] + 1));
  31684. continue;
  31685. }
  31686. }
  31687. if ($statusCode >= 400 && $statusCode <= 599) {
  31688. throw $this->failResponse($job, $response, $response->getStatusMessage());
  31689. }
  31690. if ($job['attributes']['storeAuth']) {
  31691. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  31692. }
  31693. if ($job['filename']) {
  31694. rename($job['filename'].'~', $job['filename']);
  31695. call_user_func($job['resolve'], $response);
  31696. } else {
  31697. call_user_func($job['resolve'], $response);
  31698. }
  31699. } catch (\Exception $e) {
  31700. if ($e instanceof TransportException && $headers) {
  31701. $e->setHeaders($headers);
  31702. $e->setStatusCode($statusCode);
  31703. }
  31704. if ($e instanceof TransportException && $response) {
  31705. $e->setResponse($response->getBody());
  31706. }
  31707. if ($e instanceof TransportException && $progress) {
  31708. $e->setResponseInfo($progress);
  31709. }
  31710. $this->rejectJob($job, $e);
  31711. }
  31712. }
  31713. foreach ($this->jobs as $i => $curlHandle) {
  31714. if (!isset($this->jobs[$i])) {
  31715. continue;
  31716. }
  31717. $curlHandle = $this->jobs[$i]['curlHandle'];
  31718. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  31719. if ($this->jobs[$i]['progress'] !== $progress) {
  31720. $this->jobs[$i]['progress'] = $progress;
  31721. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  31722. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  31723. $this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Content-length header indicates ' . $progress['download_content_length'] . ' bytes. Allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
  31724. }
  31725. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  31726. $this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . $progress['size_download'] . ' of allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
  31727. }
  31728. }
  31729. }
  31730. }
  31731. }
  31732. private function handleRedirect(array $job, Response $response)
  31733. {
  31734. if ($locationHeader = $response->getHeader('location')) {
  31735. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  31736. $targetUrl = $locationHeader;
  31737. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  31738. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  31739. } elseif ('/' === $locationHeader[0]) {
  31740. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  31741. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  31742. } else {
  31743. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  31744. }
  31745. }
  31746. if (!empty($targetUrl)) {
  31747. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  31748. return $targetUrl;
  31749. }
  31750. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  31751. }
  31752. private function isAuthenticatedRetryNeeded(array $job, Response $response)
  31753. {
  31754. if (in_array($response->getStatusCode(), array(401, 403)) && $job['attributes']['retryAuthFailure']) {
  31755. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders());
  31756. if ($result['retry']) {
  31757. return $result;
  31758. }
  31759. }
  31760. $locationHeader = $response->getHeader('location');
  31761. $needsAuthRetry = false;
  31762. if (
  31763. $job['origin'] === 'bitbucket.org'
  31764. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  31765. && substr($job['url'], -4) === '.zip'
  31766. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  31767. && preg_match('{^text/html\b}i', $response->getHeader('content-type'))
  31768. ) {
  31769. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  31770. }
  31771. if (
  31772. $response->getStatusCode() === 404
  31773. && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  31774. && false !== strpos($job['url'], 'archive.zip')
  31775. ) {
  31776. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  31777. }
  31778. if ($needsAuthRetry) {
  31779. if ($job['attributes']['retryAuthFailure']) {
  31780. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401);
  31781. if ($result['retry']) {
  31782. return $result;
  31783. }
  31784. }
  31785. throw $this->failResponse($job, $response, $needsAuthRetry);
  31786. }
  31787. return array('retry' => false, 'storeAuth' => false);
  31788. }
  31789. private function restartJob(array $job, $url, array $attributes = array())
  31790. {
  31791. if ($job['filename']) {
  31792. @unlink($job['filename'].'~');
  31793. }
  31794. $attributes = array_merge($job['attributes'], $attributes);
  31795. $origin = Url::getOrigin($this->config, $url);
  31796. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  31797. }
  31798. private function failResponse(array $job, Response $response, $errorMessage)
  31799. {
  31800. if ($job['filename']) {
  31801. @unlink($job['filename'].'~');
  31802. }
  31803. $details = '';
  31804. if (in_array(strtolower($response->getHeader('content-type')), array('application/json', 'application/json; charset=utf-8'), true)) {
  31805. $details = ':'.PHP_EOL.substr($response->getBody(), 0, 200).(strlen($response->getBody()) > 200 ? '...' : '');
  31806. }
  31807. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
  31808. }
  31809. private function rejectJob(array $job, \Exception $e)
  31810. {
  31811. if (is_resource($job['headerHandle'])) {
  31812. fclose($job['headerHandle']);
  31813. }
  31814. if (is_resource($job['bodyHandle'])) {
  31815. fclose($job['bodyHandle']);
  31816. }
  31817. if ($job['filename']) {
  31818. @unlink($job['filename'].'~');
  31819. }
  31820. call_user_func($job['reject'], $e);
  31821. }
  31822. private function checkCurlResult($code)
  31823. {
  31824. if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
  31825. throw new \RuntimeException(
  31826. isset($this->multiErrors[$code])
  31827. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  31828. : 'Unexpected cURL error: ' . $code
  31829. );
  31830. }
  31831. }
  31832. }
  31833. <?php
  31834. namespace Composer\Util\Http;
  31835. class CurlResponse extends Response
  31836. {
  31837. private $curlInfo;
  31838. public function __construct(array $request, $code, array $headers, $body, array $curlInfo)
  31839. {
  31840. parent::__construct($request, $code, $headers, $body);
  31841. $this->curlInfo = $curlInfo;
  31842. }
  31843. public function getCurlInfo()
  31844. {
  31845. return $this->curlInfo;
  31846. }
  31847. }
  31848. <?php
  31849. namespace Composer\Util\Http;
  31850. class ProxyHelper
  31851. {
  31852. public static function getProxyData()
  31853. {
  31854. $httpProxy = null;
  31855. $httpsProxy = null;
  31856. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  31857. if ($env = self::getProxyEnv(array('http_proxy', 'HTTP_PROXY'), $name)) {
  31858. $httpProxy = self::checkProxy($env, $name);
  31859. }
  31860. }
  31861. if ($env = self::getProxyEnv(array('CGI_HTTP_PROXY'), $name)) {
  31862. $httpProxy = self::checkProxy($env, $name);
  31863. }
  31864. if ($env = self::getProxyEnv(array('https_proxy', 'HTTPS_PROXY'), $name)) {
  31865. $httpsProxy = self::checkProxy($env, $name);
  31866. } else {
  31867. $httpsProxy = $httpProxy;
  31868. }
  31869. $noProxy = self::getProxyEnv(array('no_proxy', 'NO_PROXY'), $name);
  31870. return array($httpProxy, $httpsProxy, $noProxy);
  31871. }
  31872. public static function getContextOptions($proxyUrl)
  31873. {
  31874. $proxy = parse_url($proxyUrl);
  31875. $proxyUrl = self::formatParsedUrl($proxy, false);
  31876. $proxyUrl = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyUrl);
  31877. $options['http']['proxy'] = $proxyUrl;
  31878. if (isset($proxy['user'])) {
  31879. $auth = rawurldecode($proxy['user']);
  31880. if (isset($proxy['pass'])) {
  31881. $auth .= ':' . rawurldecode($proxy['pass']);
  31882. }
  31883. $auth = base64_encode($auth);
  31884. $options['http']['header'] = "Proxy-Authorization: Basic {$auth}";
  31885. }
  31886. return $options;
  31887. }
  31888. public static function setRequestFullUri($requestUrl, array &$options)
  31889. {
  31890. if ('http' === parse_url($requestUrl, PHP_URL_SCHEME)) {
  31891. $options['http']['request_fulluri'] = true;
  31892. } else {
  31893. unset($options['http']['request_fulluri']);
  31894. }
  31895. }
  31896. private static function getProxyEnv(array $names, &$name)
  31897. {
  31898. foreach ($names as $name) {
  31899. if (!empty($_SERVER[$name])) {
  31900. return $_SERVER[$name];
  31901. }
  31902. }
  31903. return null;
  31904. }
  31905. private static function checkProxy($proxyUrl, $envName)
  31906. {
  31907. $error = sprintf('malformed %s url', $envName);
  31908. $proxy = parse_url($proxyUrl);
  31909. if (!isset($proxy['host'])) {
  31910. throw new \RuntimeException($error);
  31911. }
  31912. $proxyUrl = self::formatParsedUrl($proxy, true);
  31913. if (!parse_url($proxyUrl, PHP_URL_PORT)) {
  31914. throw new \RuntimeException($error);
  31915. }
  31916. return $proxyUrl;
  31917. }
  31918. private static function formatParsedUrl(array $proxy, $includeAuth)
  31919. {
  31920. $proxyUrl = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : '';
  31921. if ($includeAuth && isset($proxy['user'])) {
  31922. $proxyUrl .= $proxy['user'];
  31923. if (isset($proxy['pass'])) {
  31924. $proxyUrl .= ':' . $proxy['pass'];
  31925. }
  31926. $proxyUrl .= '@';
  31927. }
  31928. $proxyUrl .= $proxy['host'];
  31929. if (isset($proxy['port'])) {
  31930. $proxyUrl .= ':' . $proxy['port'];
  31931. } elseif (strpos($proxyUrl, 'http://') === 0) {
  31932. $proxyUrl .= ':80';
  31933. } elseif (strpos($proxyUrl, 'https://') === 0) {
  31934. $proxyUrl .= ':443';
  31935. }
  31936. return $proxyUrl;
  31937. }
  31938. }
  31939. <?php
  31940. namespace Composer\Util\Http;
  31941. use Composer\Downloader\TransportException;
  31942. use Composer\Util\NoProxyPattern;
  31943. use Composer\Util\Url;
  31944. class ProxyManager
  31945. {
  31946. private $error = null;
  31947. private $fullProxy;
  31948. private $safeProxy;
  31949. private $streams;
  31950. private $hasProxy;
  31951. private $info = null;
  31952. private $lastProxy = null;
  31953. private $noProxyHandler = null;
  31954. private static $instance = null;
  31955. private function __construct()
  31956. {
  31957. $this->fullProxy = $this->safeProxy = array(
  31958. 'http' => null,
  31959. 'https' => null,
  31960. );
  31961. $this->streams['http'] = $this->streams['https'] = array(
  31962. 'options' => null,
  31963. );
  31964. $this->hasProxy = false;
  31965. $this->initProxyData();
  31966. }
  31967. public static function getInstance()
  31968. {
  31969. if (!self::$instance) {
  31970. self::$instance = new self();
  31971. }
  31972. return self::$instance;
  31973. }
  31974. public static function reset()
  31975. {
  31976. self::$instance = null;
  31977. }
  31978. public function getProxyForRequest($requestUrl)
  31979. {
  31980. if ($this->error) {
  31981. throw new TransportException('Unable to use a proxy: '.$this->error);
  31982. }
  31983. $scheme = parse_url($requestUrl, PHP_URL_SCHEME) ?: 'http';
  31984. $proxyUrl = '';
  31985. $options = array();
  31986. $formattedProxyUrl = '';
  31987. if ($this->hasProxy && in_array($scheme, array('http', 'https'), true) && $this->fullProxy[$scheme]) {
  31988. if ($this->noProxy($requestUrl)) {
  31989. $formattedProxyUrl = 'excluded by no_proxy';
  31990. } else {
  31991. $proxyUrl = $this->fullProxy[$scheme];
  31992. $options = $this->streams[$scheme]['options'];
  31993. ProxyHelper::setRequestFullUri($requestUrl, $options);
  31994. $formattedProxyUrl = $this->safeProxy[$scheme];
  31995. }
  31996. }
  31997. return new RequestProxy($proxyUrl, $options, $formattedProxyUrl);
  31998. }
  31999. public function isProxying()
  32000. {
  32001. return $this->hasProxy;
  32002. }
  32003. public function getFormattedProxy()
  32004. {
  32005. return $this->hasProxy ? $this->info : $this->error;
  32006. }
  32007. private function initProxyData()
  32008. {
  32009. try {
  32010. list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData();
  32011. } catch (\RuntimeException $e) {
  32012. $this->error = $e->getMessage();
  32013. return;
  32014. }
  32015. $info = array();
  32016. if ($httpProxy) {
  32017. $info[] = $this->setData($httpProxy, 'http');
  32018. }
  32019. if ($httpsProxy) {
  32020. $info[] = $this->setData($httpsProxy, 'https');
  32021. }
  32022. if ($this->hasProxy) {
  32023. $this->info = implode(', ', $info);
  32024. if ($noProxy) {
  32025. $this->noProxyHandler = new NoProxyPattern($noProxy);
  32026. }
  32027. }
  32028. }
  32029. private function setData($url, $scheme)
  32030. {
  32031. $safeProxy = Url::sanitize($url);
  32032. $this->fullProxy[$scheme] = $url;
  32033. $this->safeProxy[$scheme] = $safeProxy;
  32034. $this->streams[$scheme]['options'] = ProxyHelper::getContextOptions($url);
  32035. $this->hasProxy = true;
  32036. return sprintf('%s=%s', $scheme, $safeProxy);
  32037. }
  32038. private function noProxy($requestUrl)
  32039. {
  32040. if ($this->noProxyHandler) {
  32041. if ($this->noProxyHandler->test($requestUrl)) {
  32042. $this->lastProxy = 'excluded by no_proxy';
  32043. return true;
  32044. }
  32045. }
  32046. return false;
  32047. }
  32048. }
  32049. <?php
  32050. namespace Composer\Util\Http;
  32051. use Composer\Util\Url;
  32052. class RequestProxy
  32053. {
  32054. private $contextOptions;
  32055. private $isSecure;
  32056. private $formattedUrl;
  32057. private $url;
  32058. public function __construct($url, array $contextOptions, $formattedUrl)
  32059. {
  32060. $this->url = $url;
  32061. $this->contextOptions = $contextOptions;
  32062. $this->formattedUrl = $formattedUrl;
  32063. $this->isSecure = 0 === strpos($url, 'https://');
  32064. }
  32065. public function getContextOptions()
  32066. {
  32067. return $this->contextOptions;
  32068. }
  32069. public function getFormattedUrl($format = '')
  32070. {
  32071. $result = '';
  32072. if ($this->formattedUrl) {
  32073. $format = $format ?: '%s';
  32074. $result = sprintf($format, $this->formattedUrl);
  32075. }
  32076. return $result;
  32077. }
  32078. public function getUrl()
  32079. {
  32080. return $this->url;
  32081. }
  32082. public function isSecure()
  32083. {
  32084. return $this->isSecure;
  32085. }
  32086. }
  32087. <?php
  32088. namespace Composer\Util\Http;
  32089. use Composer\Json\JsonFile;
  32090. use Composer\Util\HttpDownloader;
  32091. class Response
  32092. {
  32093. private $request;
  32094. private $code;
  32095. private $headers;
  32096. private $body;
  32097. public function __construct(array $request, $code, array $headers, $body)
  32098. {
  32099. if (!isset($request['url'])) {
  32100. throw new \LogicException('url key missing from request array');
  32101. }
  32102. $this->request = $request;
  32103. $this->code = (int) $code;
  32104. $this->headers = $headers;
  32105. $this->body = $body;
  32106. }
  32107. public function getStatusCode()
  32108. {
  32109. return $this->code;
  32110. }
  32111. public function getStatusMessage()
  32112. {
  32113. $value = null;
  32114. foreach ($this->headers as $header) {
  32115. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  32116. $value = $header;
  32117. }
  32118. }
  32119. return $value;
  32120. }
  32121. public function getHeaders()
  32122. {
  32123. return $this->headers;
  32124. }
  32125. public function getHeader($name)
  32126. {
  32127. return self::findHeaderValue($this->headers, $name);
  32128. }
  32129. public function getBody()
  32130. {
  32131. return $this->body;
  32132. }
  32133. public function decodeJson()
  32134. {
  32135. return JsonFile::parseJson($this->body, $this->request['url']);
  32136. }
  32137. public function collect()
  32138. {
  32139. $this->request = $this->code = $this->headers = $this->body = null;
  32140. }
  32141. public static function findHeaderValue(array $headers, $name)
  32142. {
  32143. $value = null;
  32144. foreach ($headers as $header) {
  32145. if (preg_match('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  32146. $value = $match[1];
  32147. }
  32148. }
  32149. return $value;
  32150. }
  32151. }
  32152. <?php
  32153. namespace Composer\Util;
  32154. use Composer\Config;
  32155. use Composer\IO\IOInterface;
  32156. use Composer\Downloader\TransportException;
  32157. use Composer\Util\Http\Response;
  32158. use Composer\Util\Http\CurlDownloader;
  32159. use Composer\Composer;
  32160. use Composer\Package\Version\VersionParser;
  32161. use Composer\Semver\Constraint\Constraint;
  32162. use Composer\Exception\IrrecoverableDownloadException;
  32163. use React\Promise\Promise;
  32164. use React\Promise\PromiseInterface;
  32165. class HttpDownloader
  32166. {
  32167. const STATUS_QUEUED = 1;
  32168. const STATUS_STARTED = 2;
  32169. const STATUS_COMPLETED = 3;
  32170. const STATUS_FAILED = 4;
  32171. const STATUS_ABORTED = 5;
  32172. private $io;
  32173. private $config;
  32174. private $jobs = array();
  32175. private $options = array();
  32176. private $runningJobs = 0;
  32177. private $maxJobs = 12;
  32178. private $curl;
  32179. private $rfs;
  32180. private $idGen = 0;
  32181. private $disabled;
  32182. private $allowAsync = false;
  32183. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  32184. {
  32185. $this->io = $io;
  32186. $this->disabled = (bool) getenv('COMPOSER_DISABLE_NETWORK');
  32187. if ($disableTls === false) {
  32188. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  32189. }
  32190. $this->options = array_replace_recursive($this->options, $options);
  32191. $this->config = $config;
  32192. if (self::isCurlEnabled()) {
  32193. $this->curl = new CurlDownloader($io, $config, $options, $disableTls);
  32194. }
  32195. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  32196. if (is_numeric($maxJobs = getenv('COMPOSER_MAX_PARALLEL_HTTP'))) {
  32197. $this->maxJobs = max(1, min(50, (int) $maxJobs));
  32198. }
  32199. }
  32200. public function get($url, $options = array())
  32201. {
  32202. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => null), true);
  32203. $this->wait($job['id']);
  32204. $response = $this->getResponse($job['id']);
  32205. if (
  32206. $this->curl
  32207. && PHP_VERSION_ID < 70000
  32208. && $response->getBody() === null
  32209. && $response->getStatusCode() === 200
  32210. && $response->getHeader('content-length') !== '0'
  32211. ) {
  32212. $this->io->writeError('<warning>cURL downloader failed to return a response, disabling it and proceeding in slow mode.</warning>');
  32213. $this->curl = null;
  32214. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => null), true);
  32215. $this->wait($job['id']);
  32216. $response = $this->getResponse($job['id']);
  32217. }
  32218. return $response;
  32219. }
  32220. public function add($url, $options = array())
  32221. {
  32222. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => null));
  32223. return $promise;
  32224. }
  32225. public function copy($url, $to, $options = array())
  32226. {
  32227. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true);
  32228. $this->wait($job['id']);
  32229. return $this->getResponse($job['id']);
  32230. }
  32231. public function addCopy($url, $to, $options = array())
  32232. {
  32233. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to));
  32234. return $promise;
  32235. }
  32236. public function getOptions()
  32237. {
  32238. return $this->options;
  32239. }
  32240. public function setOptions(array $options)
  32241. {
  32242. $this->options = array_replace_recursive($this->options, $options);
  32243. }
  32244. private function addJob($request, $sync = false)
  32245. {
  32246. $request['options'] = array_replace_recursive($this->options, $request['options']);
  32247. $job = array(
  32248. 'id' => $this->idGen++,
  32249. 'status' => self::STATUS_QUEUED,
  32250. 'request' => $request,
  32251. 'sync' => $sync,
  32252. 'origin' => Url::getOrigin($this->config, $request['url']),
  32253. );
  32254. if (!$sync && !$this->allowAsync) {
  32255. 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');
  32256. }
  32257. if (preg_match('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  32258. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  32259. }
  32260. $rfs = $this->rfs;
  32261. if ($this->canUseCurl($job)) {
  32262. $resolver = function ($resolve, $reject) use (&$job) {
  32263. $job['status'] = HttpDownloader::STATUS_QUEUED;
  32264. $job['resolve'] = $resolve;
  32265. $job['reject'] = $reject;
  32266. };
  32267. } else {
  32268. $resolver = function ($resolve, $reject) use (&$job, $rfs) {
  32269. $url = $job['request']['url'];
  32270. $options = $job['request']['options'];
  32271. $job['status'] = HttpDownloader::STATUS_STARTED;
  32272. if ($job['request']['copyTo']) {
  32273. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  32274. $headers = $rfs->getLastHeaders();
  32275. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  32276. $resolve($response);
  32277. } else {
  32278. $body = $rfs->getContents($job['origin'], $url, false , $options);
  32279. $headers = $rfs->getLastHeaders();
  32280. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  32281. $resolve($response);
  32282. }
  32283. };
  32284. }
  32285. $downloader = $this;
  32286. $curl = $this->curl;
  32287. $canceler = function () use (&$job, $curl) {
  32288. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  32289. $job['status'] = HttpDownloader::STATUS_ABORTED;
  32290. }
  32291. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  32292. return;
  32293. }
  32294. $job['status'] = HttpDownloader::STATUS_ABORTED;
  32295. if (isset($job['curl_id'])) {
  32296. $curl->abortRequest($job['curl_id']);
  32297. }
  32298. throw new IrrecoverableDownloadException('Download of ' . Url::sanitize($job['request']['url']) . ' canceled');
  32299. };
  32300. $promise = new Promise($resolver, $canceler);
  32301. $promise = $promise->then(function ($response) use (&$job, $downloader) {
  32302. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  32303. $job['response'] = $response;
  32304. $downloader->markJobDone();
  32305. return $response;
  32306. }, function ($e) use (&$job, $downloader) {
  32307. $job['status'] = HttpDownloader::STATUS_FAILED;
  32308. $job['exception'] = $e;
  32309. $downloader->markJobDone();
  32310. throw $e;
  32311. });
  32312. $this->jobs[$job['id']] = &$job;
  32313. if ($this->runningJobs < $this->maxJobs) {
  32314. $this->startJob($job['id']);
  32315. }
  32316. return array($job, $promise);
  32317. }
  32318. private function startJob($id)
  32319. {
  32320. $job = &$this->jobs[$id];
  32321. if ($job['status'] !== self::STATUS_QUEUED) {
  32322. return;
  32323. }
  32324. $job['status'] = self::STATUS_STARTED;
  32325. $this->runningJobs++;
  32326. $resolve = $job['resolve'];
  32327. $reject = $job['reject'];
  32328. $url = $job['request']['url'];
  32329. $options = $job['request']['options'];
  32330. $origin = $job['origin'];
  32331. if ($this->disabled) {
  32332. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  32333. $resolve(new Response(array('url' => $url), 304, array(), ''));
  32334. } else {
  32335. $e = new TransportException('Network disabled, request canceled: '.Url::sanitize($url), 499);
  32336. $e->setStatusCode(499);
  32337. $reject($e);
  32338. }
  32339. return;
  32340. }
  32341. try {
  32342. if ($job['request']['copyTo']) {
  32343. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  32344. } else {
  32345. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  32346. }
  32347. } catch (\Exception $exception) {
  32348. $reject($exception);
  32349. }
  32350. }
  32351. public function markJobDone()
  32352. {
  32353. $this->runningJobs--;
  32354. }
  32355. public function wait($index = null)
  32356. {
  32357. do {
  32358. $jobCount = $this->countActiveJobs($index);
  32359. } while ($jobCount);
  32360. }
  32361. public function enableAsync()
  32362. {
  32363. $this->allowAsync = true;
  32364. }
  32365. public function countActiveJobs($index = null)
  32366. {
  32367. if ($this->runningJobs < $this->maxJobs) {
  32368. foreach ($this->jobs as $job) {
  32369. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  32370. $this->startJob($job['id']);
  32371. }
  32372. }
  32373. }
  32374. if ($this->curl) {
  32375. $this->curl->tick();
  32376. }
  32377. if (null !== $index) {
  32378. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  32379. }
  32380. $active = 0;
  32381. foreach ($this->jobs as $job) {
  32382. if ($job['status'] < self::STATUS_COMPLETED) {
  32383. $active++;
  32384. } elseif (!$job['sync']) {
  32385. unset($this->jobs[$job['id']]);
  32386. }
  32387. }
  32388. return $active;
  32389. }
  32390. private function getResponse($index)
  32391. {
  32392. if (!isset($this->jobs[$index])) {
  32393. throw new \LogicException('Invalid request id');
  32394. }
  32395. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  32396. throw $this->jobs[$index]['exception'];
  32397. }
  32398. if (!isset($this->jobs[$index]['response'])) {
  32399. throw new \LogicException('Response not available yet, call wait() first');
  32400. }
  32401. $resp = $this->jobs[$index]['response'];
  32402. unset($this->jobs[$index]);
  32403. return $resp;
  32404. }
  32405. public static function outputWarnings(IOInterface $io, $url, $data)
  32406. {
  32407. foreach (array('warning', 'info') as $type) {
  32408. if (empty($data[$type])) {
  32409. continue;
  32410. }
  32411. if (!empty($data[$type . '-versions'])) {
  32412. $versionParser = new VersionParser();
  32413. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  32414. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  32415. if (!$constraint->matches($composer)) {
  32416. continue;
  32417. }
  32418. }
  32419. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$data[$type].'</'.$type.'>');
  32420. }
  32421. }
  32422. public static function getExceptionHints(\Exception $e)
  32423. {
  32424. if (!$e instanceof TransportException) {
  32425. return null;
  32426. }
  32427. if (
  32428. false !== strpos($e->getMessage(), 'Resolving timed out')
  32429. || false !== strpos($e->getMessage(), 'Could not resolve host')
  32430. ) {
  32431. Silencer::suppress();
  32432. $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array(
  32433. 'ssl' => array('verify_peer' => false),
  32434. 'http' => array('follow_location' => false, 'ignore_errors' => true),
  32435. )));
  32436. Silencer::restore();
  32437. if (false !== $testConnectivity) {
  32438. return array(
  32439. '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>',
  32440. );
  32441. }
  32442. return array(
  32443. '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>',
  32444. );
  32445. }
  32446. return null;
  32447. }
  32448. private function canUseCurl(array $job)
  32449. {
  32450. if (!$this->curl) {
  32451. return false;
  32452. }
  32453. if (!preg_match('{^https?://}i', $job['request']['url'])) {
  32454. return false;
  32455. }
  32456. if (!empty($job['request']['options']['ssl']['allow_self_signed'])) {
  32457. return false;
  32458. }
  32459. return true;
  32460. }
  32461. public static function isCurlEnabled()
  32462. {
  32463. return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
  32464. }
  32465. }
  32466. <?php
  32467. namespace Composer\Util;
  32468. use Composer\XdebugHandler\XdebugHandler;
  32469. class IniHelper
  32470. {
  32471. public static function getAll()
  32472. {
  32473. return XdebugHandler::getAllIniFiles();
  32474. }
  32475. public static function getMessage()
  32476. {
  32477. $paths = self::getAll();
  32478. if (empty($paths[0])) {
  32479. array_shift($paths);
  32480. }
  32481. $ini = array_shift($paths);
  32482. if (empty($ini)) {
  32483. return 'A php.ini file does not exist. You will have to create one.';
  32484. }
  32485. if (!empty($paths)) {
  32486. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  32487. }
  32488. return 'The php.ini used by your command-line PHP is: '.$ini;
  32489. }
  32490. }
  32491. <?php
  32492. namespace Composer\Util;
  32493. use React\Promise\CancellablePromiseInterface;
  32494. use Symfony\Component\Console\Helper\ProgressBar;
  32495. use React\Promise\PromiseInterface;
  32496. class Loop
  32497. {
  32498. private $httpDownloader;
  32499. private $processExecutor;
  32500. private $currentPromises = array();
  32501. private $waitIndex = 0;
  32502. public function __construct(HttpDownloader $httpDownloader, ProcessExecutor $processExecutor = null)
  32503. {
  32504. $this->httpDownloader = $httpDownloader;
  32505. $this->httpDownloader->enableAsync();
  32506. $this->processExecutor = $processExecutor;
  32507. if ($this->processExecutor) {
  32508. $this->processExecutor->enableAsync();
  32509. }
  32510. }
  32511. public function getHttpDownloader()
  32512. {
  32513. return $this->httpDownloader;
  32514. }
  32515. public function getProcessExecutor()
  32516. {
  32517. return $this->processExecutor;
  32518. }
  32519. public function wait(array $promises, ProgressBar $progress = null)
  32520. {
  32521. $uncaught = null;
  32522. \React\Promise\all($promises)->then(
  32523. function () {
  32524. },
  32525. function ($e) use (&$uncaught) {
  32526. $uncaught = $e;
  32527. }
  32528. );
  32529. $waitIndex = $this->waitIndex++;
  32530. $this->currentPromises[$waitIndex] = $promises;
  32531. if ($progress) {
  32532. $totalJobs = 0;
  32533. $totalJobs += $this->httpDownloader->countActiveJobs();
  32534. if ($this->processExecutor) {
  32535. $totalJobs += $this->processExecutor->countActiveJobs();
  32536. }
  32537. $progress->start($totalJobs);
  32538. }
  32539. $lastUpdate = 0;
  32540. while (true) {
  32541. $activeJobs = 0;
  32542. $activeJobs += $this->httpDownloader->countActiveJobs();
  32543. if ($this->processExecutor) {
  32544. $activeJobs += $this->processExecutor->countActiveJobs();
  32545. }
  32546. if ($progress && microtime(true) - $lastUpdate > 0.1) {
  32547. $lastUpdate = microtime(true);
  32548. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  32549. }
  32550. if (!$activeJobs) {
  32551. break;
  32552. }
  32553. }
  32554. if ($progress) {
  32555. $progress->finish();
  32556. }
  32557. unset($this->currentPromises[$waitIndex]);
  32558. if ($uncaught) {
  32559. throw $uncaught;
  32560. }
  32561. }
  32562. public function abortJobs()
  32563. {
  32564. foreach ($this->currentPromises as $promiseGroup) {
  32565. foreach ($promiseGroup as $promise) {
  32566. if ($promise instanceof CancellablePromiseInterface) {
  32567. $promise->cancel();
  32568. }
  32569. }
  32570. }
  32571. }
  32572. }
  32573. <?php
  32574. namespace Composer\Util;
  32575. @trigger_error('Composer\Util\MetadataMinifier is deprecated, use Composer\MetadataMinifier\MetadataMinifier from composer/metadata-minifier instead.', E_USER_DEPRECATED);
  32576. class MetadataMinifier extends \Composer\MetadataMinifier\MetadataMinifier
  32577. {
  32578. }
  32579. <?php
  32580. namespace Composer\Util;
  32581. use stdClass;
  32582. class NoProxyPattern
  32583. {
  32584. protected $hostNames = array();
  32585. protected $rules = array();
  32586. protected $noproxy;
  32587. public function __construct($pattern)
  32588. {
  32589. $this->hostNames = preg_split('{[\s,]+}', $pattern, -1, PREG_SPLIT_NO_EMPTY);
  32590. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  32591. }
  32592. public function test($url)
  32593. {
  32594. if ($this->noproxy) {
  32595. return true;
  32596. }
  32597. if (!$urlData = $this->getUrlData($url)) {
  32598. return false;
  32599. }
  32600. foreach ($this->hostNames as $index => $hostName) {
  32601. if ($this->match($index, $hostName, $urlData)) {
  32602. return true;
  32603. }
  32604. }
  32605. return false;
  32606. }
  32607. protected function getUrlData($url)
  32608. {
  32609. if (!$host = parse_url($url, PHP_URL_HOST)) {
  32610. return false;
  32611. }
  32612. $port = parse_url($url, PHP_URL_PORT);
  32613. if (empty($port)) {
  32614. switch (parse_url($url, PHP_URL_SCHEME)) {
  32615. case 'http':
  32616. $port = 80;
  32617. break;
  32618. case 'https':
  32619. $port = 443;
  32620. break;
  32621. }
  32622. }
  32623. $hostName = $host . ($port ? ':' . $port : '');
  32624. list($host, $port, $err) = $this->splitHostPort($hostName);
  32625. if ($err || !$this->ipCheckData($host, $ipdata)) {
  32626. return false;
  32627. }
  32628. return $this->makeData($host, $port, $ipdata);
  32629. }
  32630. protected function match($index, $hostName, $url)
  32631. {
  32632. if (!$rule = $this->getRule($index, $hostName)) {
  32633. return false;
  32634. }
  32635. if ($rule->ipdata) {
  32636. if (!$url->ipdata) {
  32637. return false;
  32638. }
  32639. if ($rule->ipdata->netmask) {
  32640. return $this->matchRange($rule->ipdata, $url->ipdata);
  32641. }
  32642. $match = $rule->ipdata->ip === $url->ipdata->ip;
  32643. } else {
  32644. $haystack = substr($url->name, -strlen($rule->name));
  32645. $match = stripos($haystack, $rule->name) === 0;
  32646. }
  32647. if ($match && $rule->port) {
  32648. $match = $rule->port === $url->port;
  32649. }
  32650. return $match;
  32651. }
  32652. protected function matchRange(stdClass $network, stdClass $target)
  32653. {
  32654. $net = unpack('C*', $network->ip);
  32655. $mask = unpack('C*', $network->netmask);
  32656. $ip = unpack('C*', $target->ip);
  32657. for ($i = 1; $i < 17; ++$i) {
  32658. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  32659. return false;
  32660. }
  32661. }
  32662. return true;
  32663. }
  32664. private function getRule($index, $hostName)
  32665. {
  32666. if (array_key_exists($index, $this->rules)) {
  32667. return $this->rules[$index];
  32668. }
  32669. $this->rules[$index] = null;
  32670. list($host, $port, $err) = $this->splitHostPort($hostName);
  32671. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  32672. return null;
  32673. }
  32674. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  32675. return $this->rules[$index];
  32676. }
  32677. private function ipCheckData($host, &$ipdata, $allowPrefix = false)
  32678. {
  32679. $ipdata = null;
  32680. $netmask = null;
  32681. $prefix = null;
  32682. $modified = false;
  32683. if (strpos($host, '/') !== false) {
  32684. list($host, $prefix) = explode('/', $host);
  32685. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  32686. return false;
  32687. }
  32688. $prefix = (int) $prefix;
  32689. $modified = true;
  32690. }
  32691. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  32692. return !$modified;
  32693. }
  32694. list($ip, $size) = $this->ipGetAddr($host);
  32695. if ($prefix !== null) {
  32696. if ($prefix > $size * 8) {
  32697. return false;
  32698. }
  32699. list($ip, $netmask) = $this->ipGetNetwork($ip, $size, $prefix);
  32700. }
  32701. $ipdata = $this->makeIpData($ip, $size, $netmask);
  32702. return true;
  32703. }
  32704. private function ipGetAddr($host)
  32705. {
  32706. $ip = inet_pton($host);
  32707. $size = strlen($ip);
  32708. $mapped = $this->ipMapTo6($ip, $size);
  32709. return array($mapped, $size);
  32710. }
  32711. private function ipGetMask($prefix, $size)
  32712. {
  32713. $mask = '';
  32714. if ($ones = floor($prefix / 8)) {
  32715. $mask = str_repeat(chr(255), (int) $ones);
  32716. }
  32717. if ($remainder = $prefix % 8) {
  32718. $mask .= chr(0xff ^ (0xff >> $remainder));
  32719. }
  32720. $mask = str_pad($mask, $size, chr(0));
  32721. return $this->ipMapTo6($mask, $size);
  32722. }
  32723. private function ipGetNetwork($rangeIp, $size, $prefix)
  32724. {
  32725. $netmask = $this->ipGetMask($prefix, $size);
  32726. $mask = unpack('C*', $netmask);
  32727. $ip = unpack('C*', $rangeIp);
  32728. $net = '';
  32729. for ($i = 1; $i < 17; ++$i) {
  32730. $net .= chr($ip[$i] & $mask[$i]);
  32731. }
  32732. return array($net, $netmask);
  32733. }
  32734. private function ipMapTo6($binary, $size)
  32735. {
  32736. if ($size === 4) {
  32737. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  32738. $binary = $prefix . $binary;
  32739. }
  32740. return $binary;
  32741. }
  32742. private function makeData($host, $port, $ipdata)
  32743. {
  32744. return (object) array(
  32745. 'host' => $host,
  32746. 'name' => '.' . ltrim($host, '.'),
  32747. 'port' => $port,
  32748. 'ipdata' => $ipdata,
  32749. );
  32750. }
  32751. private function makeIpData($ip, $size, $netmask)
  32752. {
  32753. return (object) array(
  32754. 'ip' => $ip,
  32755. 'size' => $size,
  32756. 'netmask' => $netmask,
  32757. );
  32758. }
  32759. private function splitHostPort($hostName)
  32760. {
  32761. $error = array('', '', true);
  32762. $port = 0;
  32763. $ip6 = '';
  32764. if ($hostName[0] === '[') {
  32765. $index = strpos($hostName, ']');
  32766. if (false === $index || $index < 3) {
  32767. return $error;
  32768. }
  32769. $ip6 = substr($hostName, 1, $index - 1);
  32770. $hostName = substr($hostName, $index + 1);
  32771. if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {
  32772. return $error;
  32773. }
  32774. }
  32775. if (substr_count($hostName, ':') === 1) {
  32776. $index = strpos($hostName, ':');
  32777. $port = substr($hostName, $index + 1);
  32778. $hostName = substr($hostName, 0, $index);
  32779. if (!$this->validateInt($port, 1, 65535)) {
  32780. return $error;
  32781. }
  32782. $port = (int) $port;
  32783. }
  32784. $host = $ip6 . $hostName;
  32785. return array($host, $port, false);
  32786. }
  32787. private function validateInt($int, $min, $max)
  32788. {
  32789. $options = array(
  32790. 'options' => array(
  32791. 'min_range' => $min,
  32792. 'max_range' => $max,
  32793. ),
  32794. );
  32795. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  32796. }
  32797. }
  32798. <?php
  32799. namespace Composer\Util;
  32800. use Composer\Package\PackageInterface;
  32801. class PackageSorter
  32802. {
  32803. public static function sortPackages(array $packages)
  32804. {
  32805. $usageList = array();
  32806. foreach ($packages as $package) {
  32807. foreach (array_merge($package->getRequires(), $package->getDevRequires()) as $link) {
  32808. $target = $link->getTarget();
  32809. $usageList[$target][] = $package->getName();
  32810. }
  32811. }
  32812. $computing = array();
  32813. $computed = array();
  32814. $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList) {
  32815. if (isset($computed[$name])) {
  32816. return $computed[$name];
  32817. }
  32818. if (isset($computing[$name])) {
  32819. return 0;
  32820. }
  32821. $computing[$name] = true;
  32822. $weight = 0;
  32823. if (isset($usageList[$name])) {
  32824. foreach ($usageList[$name] as $user) {
  32825. $weight -= 1 - $computeImportance($user);
  32826. }
  32827. }
  32828. unset($computing[$name]);
  32829. $computed[$name] = $weight;
  32830. return $weight;
  32831. };
  32832. $weightList = array();
  32833. foreach ($packages as $index => $package) {
  32834. $weight = $computeImportance($package->getName());
  32835. $weightList[$index] = $weight;
  32836. }
  32837. $stable_sort = function (&$array) {
  32838. static $transform, $restore;
  32839. $i = 0;
  32840. if (!$transform) {
  32841. $transform = function (&$v, $k) use (&$i) {
  32842. $v = array($v, ++$i, $k, $v);
  32843. };
  32844. $restore = function (&$v) {
  32845. $v = $v[3];
  32846. };
  32847. }
  32848. array_walk($array, $transform);
  32849. asort($array);
  32850. array_walk($array, $restore);
  32851. };
  32852. $stable_sort($weightList);
  32853. $sortedPackages = array();
  32854. foreach (array_keys($weightList) as $index) {
  32855. $sortedPackages[] = $packages[$index];
  32856. }
  32857. return $sortedPackages;
  32858. }
  32859. }
  32860. <?php
  32861. namespace Composer\Util;
  32862. use Composer\IO\IOInterface;
  32863. use Symfony\Component\Process\Process;
  32864. class Perforce
  32865. {
  32866. protected $path;
  32867. protected $p4Depot;
  32868. protected $p4Client;
  32869. protected $p4User;
  32870. protected $p4Password;
  32871. protected $p4Port;
  32872. protected $p4Stream;
  32873. protected $p4ClientSpec;
  32874. protected $p4DepotType;
  32875. protected $p4Branch;
  32876. protected $process;
  32877. protected $uniquePerforceClientName;
  32878. protected $windowsFlag;
  32879. protected $commandResult;
  32880. protected $io;
  32881. protected $filesystem;
  32882. public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io)
  32883. {
  32884. $this->windowsFlag = $isWindows;
  32885. $this->p4Port = $port;
  32886. $this->initializePath($path);
  32887. $this->process = $process;
  32888. $this->initialize($repoConfig);
  32889. $this->io = $io;
  32890. }
  32891. public static function create($repoConfig, $port, $path, ProcessExecutor $process, IOInterface $io)
  32892. {
  32893. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  32894. }
  32895. public static function checkServerExists($url, ProcessExecutor $processExecutor)
  32896. {
  32897. $output = null;
  32898. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $output);
  32899. }
  32900. public function initialize($repoConfig)
  32901. {
  32902. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  32903. if (!$repoConfig) {
  32904. return;
  32905. }
  32906. if (isset($repoConfig['unique_perforce_client_name'])) {
  32907. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  32908. }
  32909. if (isset($repoConfig['depot'])) {
  32910. $this->p4Depot = $repoConfig['depot'];
  32911. }
  32912. if (isset($repoConfig['branch'])) {
  32913. $this->p4Branch = $repoConfig['branch'];
  32914. }
  32915. if (isset($repoConfig['p4user'])) {
  32916. $this->p4User = $repoConfig['p4user'];
  32917. } else {
  32918. $this->p4User = $this->getP4variable('P4USER');
  32919. }
  32920. if (isset($repoConfig['p4password'])) {
  32921. $this->p4Password = $repoConfig['p4password'];
  32922. }
  32923. }
  32924. public function initializeDepotAndBranch($depot, $branch)
  32925. {
  32926. if (isset($depot)) {
  32927. $this->p4Depot = $depot;
  32928. }
  32929. if (isset($branch)) {
  32930. $this->p4Branch = $branch;
  32931. }
  32932. }
  32933. public function generateUniquePerforceClientName()
  32934. {
  32935. return gethostname() . "_" . time();
  32936. }
  32937. public function cleanupClientSpec()
  32938. {
  32939. $client = $this->getClient();
  32940. $task = 'client -d ' . ProcessExecutor::escape($client);
  32941. $useP4Client = false;
  32942. $command = $this->generateP4Command($task, $useP4Client);
  32943. $this->executeCommand($command);
  32944. $clientSpec = $this->getP4ClientSpec();
  32945. $fileSystem = $this->getFilesystem();
  32946. $fileSystem->remove($clientSpec);
  32947. }
  32948. protected function executeCommand($command)
  32949. {
  32950. $this->commandResult = '';
  32951. return $this->process->execute($command, $this->commandResult);
  32952. }
  32953. public function getClient()
  32954. {
  32955. if (!isset($this->p4Client)) {
  32956. $cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
  32957. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  32958. }
  32959. return $this->p4Client;
  32960. }
  32961. protected function getPath()
  32962. {
  32963. return $this->path;
  32964. }
  32965. public function initializePath($path)
  32966. {
  32967. $this->path = $path;
  32968. $fs = $this->getFilesystem();
  32969. $fs->ensureDirectoryExists($path);
  32970. }
  32971. protected function getPort()
  32972. {
  32973. return $this->p4Port;
  32974. }
  32975. public function setStream($stream)
  32976. {
  32977. $this->p4Stream = $stream;
  32978. $index = strrpos($stream, '/');
  32979. if ($index > 2) {
  32980. $this->p4DepotType = 'stream';
  32981. }
  32982. }
  32983. public function isStream()
  32984. {
  32985. return is_string($this->p4DepotType) && (strcmp($this->p4DepotType, 'stream') === 0);
  32986. }
  32987. public function getStream()
  32988. {
  32989. if (!isset($this->p4Stream)) {
  32990. if ($this->isStream()) {
  32991. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  32992. } else {
  32993. $this->p4Stream = '//' . $this->p4Depot;
  32994. }
  32995. }
  32996. return $this->p4Stream;
  32997. }
  32998. public function getStreamWithoutLabel($stream)
  32999. {
  33000. $index = strpos($stream, '@');
  33001. if ($index === false) {
  33002. return $stream;
  33003. }
  33004. return substr($stream, 0, $index);
  33005. }
  33006. public function getP4ClientSpec()
  33007. {
  33008. return $this->path . '/' . $this->getClient() . '.p4.spec';
  33009. }
  33010. public function getUser()
  33011. {
  33012. return $this->p4User;
  33013. }
  33014. public function setUser($user)
  33015. {
  33016. $this->p4User = $user;
  33017. }
  33018. public function queryP4User()
  33019. {
  33020. $this->getUser();
  33021. if (strlen((string) $this->p4User) > 0) {
  33022. return;
  33023. }
  33024. $this->p4User = $this->getP4variable('P4USER');
  33025. if (strlen((string) $this->p4User) > 0) {
  33026. return;
  33027. }
  33028. $this->p4User = $this->io->ask('Enter P4 User:');
  33029. if ($this->windowsFlag) {
  33030. $command = 'p4 set P4USER=' . $this->p4User;
  33031. } else {
  33032. $command = 'export P4USER=' . $this->p4User;
  33033. }
  33034. $this->executeCommand($command);
  33035. }
  33036. protected function getP4variable($name)
  33037. {
  33038. if ($this->windowsFlag) {
  33039. $command = 'p4 set';
  33040. $this->executeCommand($command);
  33041. $result = trim($this->commandResult);
  33042. $resArray = explode(PHP_EOL, $result);
  33043. foreach ($resArray as $line) {
  33044. $fields = explode('=', $line);
  33045. if (strcmp($name, $fields[0]) == 0) {
  33046. $index = strpos($fields[1], ' ');
  33047. if ($index === false) {
  33048. $value = $fields[1];
  33049. } else {
  33050. $value = substr($fields[1], 0, $index);
  33051. }
  33052. $value = trim($value);
  33053. return $value;
  33054. }
  33055. }
  33056. return null;
  33057. }
  33058. $command = 'echo $' . $name;
  33059. $this->executeCommand($command);
  33060. $result = trim($this->commandResult);
  33061. return $result;
  33062. }
  33063. public function queryP4Password()
  33064. {
  33065. if (isset($this->p4Password)) {
  33066. return $this->p4Password;
  33067. }
  33068. $password = $this->getP4variable('P4PASSWD');
  33069. if (strlen((string) $password) <= 0) {
  33070. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  33071. }
  33072. $this->p4Password = $password;
  33073. return $password;
  33074. }
  33075. public function generateP4Command($command, $useClient = true)
  33076. {
  33077. $p4Command = 'p4 ';
  33078. $p4Command .= '-u ' . $this->getUser() . ' ';
  33079. if ($useClient) {
  33080. $p4Command .= '-c ' . $this->getClient() . ' ';
  33081. }
  33082. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  33083. return $p4Command;
  33084. }
  33085. public function isLoggedIn()
  33086. {
  33087. $command = $this->generateP4Command('login -s', false);
  33088. $exitCode = $this->executeCommand($command);
  33089. if ($exitCode) {
  33090. $errorOutput = $this->process->getErrorOutput();
  33091. $index = strpos($errorOutput, $this->getUser());
  33092. if ($index === false) {
  33093. $index = strpos($errorOutput, 'p4');
  33094. if ($index === false) {
  33095. return false;
  33096. }
  33097. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  33098. }
  33099. throw new \Exception('Invalid user name: ' . $this->getUser());
  33100. }
  33101. return true;
  33102. }
  33103. public function connectClient()
  33104. {
  33105. $p4CreateClientCommand = $this->generateP4Command(
  33106. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  33107. );
  33108. $this->executeCommand($p4CreateClientCommand);
  33109. }
  33110. public function syncCodeBase($sourceReference)
  33111. {
  33112. $prevDir = getcwd();
  33113. chdir($this->path);
  33114. $p4SyncCommand = $this->generateP4Command('sync -f ');
  33115. if (null !== $sourceReference) {
  33116. $p4SyncCommand .= '@' . $sourceReference;
  33117. }
  33118. $this->executeCommand($p4SyncCommand);
  33119. chdir($prevDir);
  33120. }
  33121. public function writeClientSpecToFile($spec)
  33122. {
  33123. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  33124. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  33125. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  33126. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  33127. fwrite($spec, 'Description:' . PHP_EOL);
  33128. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  33129. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  33130. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  33131. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  33132. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  33133. if ($this->isStream()) {
  33134. fwrite($spec, 'Stream:' . PHP_EOL);
  33135. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  33136. } else {
  33137. fwrite(
  33138. $spec,
  33139. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  33140. );
  33141. }
  33142. }
  33143. public function writeP4ClientSpec()
  33144. {
  33145. $clientSpec = $this->getP4ClientSpec();
  33146. $spec = fopen($clientSpec, 'w');
  33147. try {
  33148. $this->writeClientSpecToFile($spec);
  33149. } catch (\Exception $e) {
  33150. fclose($spec);
  33151. throw $e;
  33152. }
  33153. fclose($spec);
  33154. }
  33155. protected function read($pipe, $name)
  33156. {
  33157. if (feof($pipe)) {
  33158. return;
  33159. }
  33160. $line = fgets($pipe);
  33161. while ($line !== false) {
  33162. $line = fgets($pipe);
  33163. }
  33164. }
  33165. public function windowsLogin($password)
  33166. {
  33167. $command = $this->generateP4Command(' login -a');
  33168. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  33169. $process = Process::fromShellCommandline($command, null, null, $password);
  33170. } else {
  33171. $process = new Process($command, null, null, $password);
  33172. }
  33173. return $process->run();
  33174. }
  33175. public function p4Login()
  33176. {
  33177. $this->queryP4User();
  33178. if (!$this->isLoggedIn()) {
  33179. $password = $this->queryP4Password();
  33180. if ($this->windowsFlag) {
  33181. $this->windowsLogin($password);
  33182. } else {
  33183. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  33184. $exitCode = $this->executeCommand($command);
  33185. if ($exitCode) {
  33186. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  33187. }
  33188. }
  33189. }
  33190. }
  33191. public function getComposerInformation($identifier)
  33192. {
  33193. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  33194. if (!$composerFileContent) {
  33195. return;
  33196. }
  33197. return json_decode($composerFileContent, true);
  33198. }
  33199. public function getFileContent($file, $identifier)
  33200. {
  33201. $path = $this->getFilePath($file, $identifier);
  33202. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  33203. $this->executeCommand($command);
  33204. $result = $this->commandResult;
  33205. if (!trim($result)) {
  33206. return null;
  33207. }
  33208. return $result;
  33209. }
  33210. public function getFilePath($file, $identifier)
  33211. {
  33212. $index = strpos($identifier, '@');
  33213. if ($index === false) {
  33214. return $identifier. '/' . $file;
  33215. }
  33216. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  33217. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  33218. $this->executeCommand($command);
  33219. $result = $this->commandResult;
  33220. $index2 = strpos($result, 'no such file(s).');
  33221. if ($index2 === false) {
  33222. $index3 = strpos($result, 'change');
  33223. if ($index3 !== false) {
  33224. $phrase = trim(substr($result, $index3));
  33225. $fields = explode(' ', $phrase);
  33226. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  33227. }
  33228. }
  33229. return null;
  33230. }
  33231. public function getBranches()
  33232. {
  33233. $possibleBranches = array();
  33234. if (!$this->isStream()) {
  33235. $possibleBranches[$this->p4Branch] = $this->getStream();
  33236. } else {
  33237. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  33238. $this->executeCommand($command);
  33239. $result = $this->commandResult;
  33240. $resArray = explode(PHP_EOL, $result);
  33241. foreach ($resArray as $line) {
  33242. $resBits = explode(' ', $line);
  33243. if (count($resBits) > 4) {
  33244. $branch = preg_replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  33245. $possibleBranches[$branch] = $resBits[1];
  33246. }
  33247. }
  33248. }
  33249. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  33250. $this->executeCommand($command);
  33251. $result = $this->commandResult;
  33252. $resArray = explode(PHP_EOL, $result);
  33253. $lastCommit = $resArray[0];
  33254. $lastCommitArr = explode(' ', $lastCommit);
  33255. $lastCommitNum = $lastCommitArr[1];
  33256. return array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
  33257. }
  33258. public function getTags()
  33259. {
  33260. $command = $this->generateP4Command('labels');
  33261. $this->executeCommand($command);
  33262. $result = $this->commandResult;
  33263. $resArray = explode(PHP_EOL, $result);
  33264. $tags = array();
  33265. foreach ($resArray as $line) {
  33266. if (strpos($line, 'Label') !== false) {
  33267. $fields = explode(' ', $line);
  33268. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  33269. }
  33270. }
  33271. return $tags;
  33272. }
  33273. public function checkStream()
  33274. {
  33275. $command = $this->generateP4Command('depots', false);
  33276. $this->executeCommand($command);
  33277. $result = $this->commandResult;
  33278. $resArray = explode(PHP_EOL, $result);
  33279. foreach ($resArray as $line) {
  33280. if (strpos($line, 'Depot') !== false) {
  33281. $fields = explode(' ', $line);
  33282. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  33283. $this->p4DepotType = $fields[3];
  33284. return $this->isStream();
  33285. }
  33286. }
  33287. }
  33288. return false;
  33289. }
  33290. protected function getChangeList($reference)
  33291. {
  33292. $index = strpos($reference, '@');
  33293. if ($index === false) {
  33294. return null;
  33295. }
  33296. $label = substr($reference, $index);
  33297. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  33298. $this->executeCommand($command);
  33299. $changes = $this->commandResult;
  33300. if (strpos($changes, 'Change') !== 0) {
  33301. return null;
  33302. }
  33303. $fields = explode(' ', $changes);
  33304. return $fields[1];
  33305. }
  33306. public function getCommitLogs($fromReference, $toReference)
  33307. {
  33308. $fromChangeList = $this->getChangeList($fromReference);
  33309. if ($fromChangeList === null) {
  33310. return null;
  33311. }
  33312. $toChangeList = $this->getChangeList($toReference);
  33313. if ($toChangeList === null) {
  33314. return null;
  33315. }
  33316. $index = strpos($fromReference, '@');
  33317. $main = substr($fromReference, 0, $index) . '/...';
  33318. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  33319. $this->executeCommand($command);
  33320. return $this->commandResult;
  33321. }
  33322. public function getFilesystem()
  33323. {
  33324. if (empty($this->filesystem)) {
  33325. $this->filesystem = new Filesystem($this->process);
  33326. }
  33327. return $this->filesystem;
  33328. }
  33329. public function setFilesystem(Filesystem $fs)
  33330. {
  33331. $this->filesystem = $fs;
  33332. }
  33333. }
  33334. <?php
  33335. namespace Composer\Util;
  33336. class Platform
  33337. {
  33338. private static $isVirtualBoxGuest = null;
  33339. private static $isWindowsSubsystemForLinux = null;
  33340. public static function putEnv($name, $value)
  33341. {
  33342. $value = (string) $value;
  33343. putenv($name . '=' . $value);
  33344. $_SERVER[$name] = $_ENV[$name] = $value;
  33345. }
  33346. public static function clearEnv($name)
  33347. {
  33348. putenv($name);
  33349. unset($_SERVER[$name], $_ENV[$name]);
  33350. }
  33351. public static function expandPath($path)
  33352. {
  33353. if (preg_match('#^~[\\/]#', $path)) {
  33354. return self::getUserDirectory() . substr($path, 1);
  33355. }
  33356. return preg_replace_callback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches) {
  33357. if (Platform::isWindows() && $matches['var'] == 'HOME') {
  33358. return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path'];
  33359. }
  33360. return getenv($matches['var']) . $matches['path'];
  33361. }, $path);
  33362. }
  33363. public static function getUserDirectory()
  33364. {
  33365. if (false !== ($home = getenv('HOME'))) {
  33366. return $home;
  33367. }
  33368. if (self::isWindows() && false !== ($home = getenv('USERPROFILE'))) {
  33369. return $home;
  33370. }
  33371. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  33372. $info = posix_getpwuid(posix_getuid());
  33373. return $info['dir'];
  33374. }
  33375. throw new \RuntimeException('Could not determine user directory');
  33376. }
  33377. public static function isWindowsSubsystemForLinux()
  33378. {
  33379. if (null === self::$isWindowsSubsystemForLinux) {
  33380. self::$isWindowsSubsystemForLinux = false;
  33381. if (self::isWindows()) {
  33382. return self::$isWindowsSubsystemForLinux = false;
  33383. }
  33384. if (
  33385. !ini_get('open_basedir')
  33386. && is_readable('/proc/version')
  33387. && false !== stripos(Silencer::call('file_get_contents', '/proc/version'), 'microsoft')
  33388. && !file_exists('/.dockerenv')
  33389. ) {
  33390. return self::$isWindowsSubsystemForLinux = true;
  33391. }
  33392. }
  33393. return self::$isWindowsSubsystemForLinux;
  33394. }
  33395. public static function isWindows()
  33396. {
  33397. return \defined('PHP_WINDOWS_VERSION_BUILD');
  33398. }
  33399. public static function strlen($str)
  33400. {
  33401. static $useMbString = null;
  33402. if (null === $useMbString) {
  33403. $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  33404. }
  33405. if ($useMbString) {
  33406. return mb_strlen($str, '8bit');
  33407. }
  33408. return \strlen($str);
  33409. }
  33410. public static function isTty($fd = null)
  33411. {
  33412. if ($fd === null) {
  33413. $fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
  33414. }
  33415. if (in_array(strtoupper(getenv('MSYSTEM') ?: ''), array('MINGW32', 'MINGW64'), true)) {
  33416. return true;
  33417. }
  33418. if (function_exists('stream_isatty')) {
  33419. return stream_isatty($fd);
  33420. }
  33421. if (function_exists('posix_isatty') && posix_isatty($fd)) {
  33422. return true;
  33423. }
  33424. $stat = @fstat($fd);
  33425. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  33426. }
  33427. public static function workaroundFilesystemIssues()
  33428. {
  33429. if (self::isVirtualBoxGuest()) {
  33430. usleep(200000);
  33431. }
  33432. }
  33433. private static function isVirtualBoxGuest()
  33434. {
  33435. if (null === self::$isVirtualBoxGuest) {
  33436. self::$isVirtualBoxGuest = false;
  33437. if (self::isWindows()) {
  33438. return self::$isVirtualBoxGuest;
  33439. }
  33440. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  33441. $processUser = posix_getpwuid(posix_geteuid());
  33442. if ($processUser && $processUser['name'] === 'vagrant') {
  33443. return self::$isVirtualBoxGuest = true;
  33444. }
  33445. }
  33446. if (getenv('COMPOSER_RUNTIME_ENV') === 'virtualbox') {
  33447. return self::$isVirtualBoxGuest = true;
  33448. }
  33449. if (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Linux') {
  33450. $process = new ProcessExecutor();
  33451. try {
  33452. if (0 === $process->execute('lsmod | grep vboxguest', $ignoredOutput)) {
  33453. return self::$isVirtualBoxGuest = true;
  33454. }
  33455. } catch (\Exception $e) {
  33456. }
  33457. }
  33458. }
  33459. return self::$isVirtualBoxGuest;
  33460. }
  33461. }
  33462. <?php
  33463. namespace Composer\Util;
  33464. use Composer\IO\IOInterface;
  33465. use Symfony\Component\Process\Process;
  33466. use Symfony\Component\Process\Exception\RuntimeException;
  33467. use React\Promise\Promise;
  33468. use React\Promise\PromiseInterface;
  33469. class ProcessExecutor
  33470. {
  33471. const STATUS_QUEUED = 1;
  33472. const STATUS_STARTED = 2;
  33473. const STATUS_COMPLETED = 3;
  33474. const STATUS_FAILED = 4;
  33475. const STATUS_ABORTED = 5;
  33476. protected static $timeout = 300;
  33477. protected $captureOutput = false;
  33478. protected $errorOutput = '';
  33479. protected $io;
  33480. private $jobs = array();
  33481. private $runningJobs = 0;
  33482. private $maxJobs = 10;
  33483. private $idGen = 0;
  33484. private $allowAsync = false;
  33485. public function __construct(IOInterface $io = null)
  33486. {
  33487. $this->io = $io;
  33488. }
  33489. public function execute($command, &$output = null, $cwd = null)
  33490. {
  33491. if (func_num_args() > 1) {
  33492. return $this->doExecute($command, $cwd, false, $output);
  33493. }
  33494. return $this->doExecute($command, $cwd, false);
  33495. }
  33496. public function executeTty($command, $cwd = null)
  33497. {
  33498. if (Platform::isTty()) {
  33499. return $this->doExecute($command, $cwd, true);
  33500. }
  33501. return $this->doExecute($command, $cwd, false);
  33502. }
  33503. private function doExecute($command, $cwd, $tty, &$output = null)
  33504. {
  33505. if ($this->io && $this->io->isDebug()) {
  33506. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  33507. if (preg_match('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  33508. return '://***:***@';
  33509. }
  33510. return '://'.$m['user'].':***@';
  33511. }, $command);
  33512. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  33513. $this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  33514. }
  33515. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  33516. $cwd = realpath(getcwd());
  33517. }
  33518. if (null !== $cwd && !is_dir($cwd)) {
  33519. throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd);
  33520. }
  33521. $this->captureOutput = func_num_args() > 3;
  33522. $this->errorOutput = '';
  33523. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  33524. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  33525. } else {
  33526. $process = new Process($command, $cwd, null, null, static::getTimeout());
  33527. }
  33528. if (!Platform::isWindows() && $tty) {
  33529. try {
  33530. $process->setTty(true);
  33531. } catch (RuntimeException $e) {
  33532. }
  33533. }
  33534. $callback = is_callable($output) ? $output : array($this, 'outputHandler');
  33535. $process->run($callback);
  33536. if ($this->captureOutput && !is_callable($output)) {
  33537. $output = $process->getOutput();
  33538. }
  33539. $this->errorOutput = $process->getErrorOutput();
  33540. return $process->getExitCode();
  33541. }
  33542. public function executeAsync($command, $cwd = null)
  33543. {
  33544. if (!$this->allowAsync) {
  33545. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  33546. }
  33547. $job = array(
  33548. 'id' => $this->idGen++,
  33549. 'status' => self::STATUS_QUEUED,
  33550. 'command' => $command,
  33551. 'cwd' => $cwd,
  33552. );
  33553. $resolver = function ($resolve, $reject) use (&$job) {
  33554. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  33555. $job['resolve'] = $resolve;
  33556. $job['reject'] = $reject;
  33557. };
  33558. $self = $this;
  33559. $canceler = function () use (&$job) {
  33560. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  33561. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  33562. }
  33563. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  33564. return;
  33565. }
  33566. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  33567. try {
  33568. if (defined('SIGINT')) {
  33569. $job['process']->signal(SIGINT);
  33570. }
  33571. } catch (\Exception $e) {
  33572. }
  33573. $job['process']->stop(1);
  33574. throw new \RuntimeException('Aborted process');
  33575. };
  33576. $promise = new Promise($resolver, $canceler);
  33577. $promise = $promise->then(function () use (&$job, $self) {
  33578. if ($job['process']->isSuccessful()) {
  33579. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  33580. } else {
  33581. $job['status'] = ProcessExecutor::STATUS_FAILED;
  33582. }
  33583. $self->markJobDone();
  33584. return $job['process'];
  33585. }, function ($e) use (&$job, $self) {
  33586. $job['status'] = ProcessExecutor::STATUS_FAILED;
  33587. $self->markJobDone();
  33588. throw $e;
  33589. });
  33590. $this->jobs[$job['id']] = &$job;
  33591. if ($this->runningJobs < $this->maxJobs) {
  33592. $this->startJob($job['id']);
  33593. }
  33594. return $promise;
  33595. }
  33596. private function startJob($id)
  33597. {
  33598. $job = &$this->jobs[$id];
  33599. if ($job['status'] !== self::STATUS_QUEUED) {
  33600. return;
  33601. }
  33602. $job['status'] = self::STATUS_STARTED;
  33603. $this->runningJobs++;
  33604. $command = $job['command'];
  33605. $cwd = $job['cwd'];
  33606. if ($this->io && $this->io->isDebug()) {
  33607. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  33608. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  33609. return '://***:***@';
  33610. }
  33611. return '://'.$m['user'].':***@';
  33612. }, $command);
  33613. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  33614. $this->io->writeError('Executing async command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  33615. }
  33616. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  33617. $cwd = realpath(getcwd());
  33618. }
  33619. if (null !== $cwd && !is_dir($cwd)) {
  33620. throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd);
  33621. }
  33622. try {
  33623. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  33624. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  33625. } else {
  33626. $process = new Process($command, $cwd, null, null, static::getTimeout());
  33627. }
  33628. } catch (\Exception $e) {
  33629. call_user_func($job['reject'], $e);
  33630. return;
  33631. } catch (\Throwable $e) {
  33632. call_user_func($job['reject'], $e);
  33633. return;
  33634. }
  33635. $job['process'] = $process;
  33636. try {
  33637. $process->start();
  33638. } catch (\Exception $e) {
  33639. call_user_func($job['reject'], $e);
  33640. return;
  33641. } catch (\Throwable $e) {
  33642. call_user_func($job['reject'], $e);
  33643. return;
  33644. }
  33645. }
  33646. public function wait($index = null)
  33647. {
  33648. while (true) {
  33649. if (!$this->countActiveJobs($index)) {
  33650. return;
  33651. }
  33652. usleep(1000);
  33653. }
  33654. }
  33655. public function enableAsync()
  33656. {
  33657. $this->allowAsync = true;
  33658. }
  33659. public function countActiveJobs($index = null)
  33660. {
  33661. foreach ($this->jobs as $job) {
  33662. if ($job['status'] === self::STATUS_STARTED) {
  33663. if (!$job['process']->isRunning()) {
  33664. call_user_func($job['resolve'], $job['process']);
  33665. }
  33666. }
  33667. if ($this->runningJobs < $this->maxJobs) {
  33668. if ($job['status'] === self::STATUS_QUEUED) {
  33669. $this->startJob($job['id']);
  33670. }
  33671. }
  33672. }
  33673. if (null !== $index) {
  33674. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  33675. }
  33676. $active = 0;
  33677. foreach ($this->jobs as $job) {
  33678. if ($job['status'] < self::STATUS_COMPLETED) {
  33679. $active++;
  33680. } else {
  33681. unset($this->jobs[$job['id']]);
  33682. }
  33683. }
  33684. return $active;
  33685. }
  33686. public function markJobDone()
  33687. {
  33688. $this->runningJobs--;
  33689. }
  33690. public function splitLines($output)
  33691. {
  33692. $output = trim((string) $output);
  33693. return $output === '' ? array() : preg_split('{\r?\n}', $output);
  33694. }
  33695. public function getErrorOutput()
  33696. {
  33697. return $this->errorOutput;
  33698. }
  33699. public function outputHandler($type, $buffer)
  33700. {
  33701. if ($this->captureOutput) {
  33702. return;
  33703. }
  33704. if (null === $this->io) {
  33705. echo $buffer;
  33706. return;
  33707. }
  33708. if (Process::ERR === $type) {
  33709. $this->io->writeErrorRaw($buffer, false);
  33710. } else {
  33711. $this->io->writeRaw($buffer, false);
  33712. }
  33713. }
  33714. public static function getTimeout()
  33715. {
  33716. return static::$timeout;
  33717. }
  33718. public static function setTimeout($timeout)
  33719. {
  33720. static::$timeout = $timeout;
  33721. }
  33722. public static function escape($argument)
  33723. {
  33724. return self::escapeArgument($argument);
  33725. }
  33726. private static function escapeArgument($argument)
  33727. {
  33728. if ('' === ($argument = (string) $argument)) {
  33729. return escapeshellarg($argument);
  33730. }
  33731. if (!Platform::isWindows()) {
  33732. return "'".str_replace("'", "'\\''", $argument)."'";
  33733. }
  33734. $argument = strtr($argument, "\n", ' ');
  33735. $quote = strpbrk($argument, " \t") !== false;
  33736. $argument = preg_replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes);
  33737. $meta = $dquotes || preg_match('/%[^%]+%|![^!]+!/', $argument);
  33738. if (!$meta && !$quote) {
  33739. $quote = strpbrk($argument, '^&|<>()') !== false;
  33740. }
  33741. if ($quote) {
  33742. $argument = '"'.preg_replace('/(\\\\*)$/', '$1$1', $argument).'"';
  33743. }
  33744. if ($meta) {
  33745. $argument = preg_replace('/(["^&|<>()%])/', '^$1', $argument);
  33746. $argument = preg_replace('/(!)/', '^^$1', $argument);
  33747. }
  33748. return $argument;
  33749. }
  33750. }
  33751. <?php
  33752. namespace Composer\Util;
  33753. use Composer\Config;
  33754. use Composer\Downloader\MaxFileSizeExceededException;
  33755. use Composer\IO\IOInterface;
  33756. use Composer\Downloader\TransportException;
  33757. use Composer\CaBundle\CaBundle;
  33758. use Composer\Util\Http\Response;
  33759. use Composer\Util\Http\ProxyManager;
  33760. class RemoteFilesystem
  33761. {
  33762. private $io;
  33763. private $config;
  33764. private $scheme;
  33765. private $bytesMax;
  33766. private $originUrl;
  33767. private $fileUrl;
  33768. private $fileName;
  33769. private $retry = false;
  33770. private $progress;
  33771. private $lastProgress;
  33772. private $options = array();
  33773. private $peerCertificateMap = array();
  33774. private $disableTls = false;
  33775. private $lastHeaders;
  33776. private $storeAuth = false;
  33777. private $authHelper;
  33778. private $degradedMode = false;
  33779. private $redirects;
  33780. private $maxRedirects = 20;
  33781. private $proxyManager;
  33782. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false, AuthHelper $authHelper = null)
  33783. {
  33784. $this->io = $io;
  33785. if ($disableTls === false) {
  33786. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  33787. } else {
  33788. $this->disableTls = true;
  33789. }
  33790. $this->options = array_replace_recursive($this->options, $options);
  33791. $this->config = $config;
  33792. $this->authHelper = isset($authHelper) ? $authHelper : new AuthHelper($io, $config);
  33793. $this->proxyManager = ProxyManager::getInstance();
  33794. }
  33795. public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array())
  33796. {
  33797. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  33798. }
  33799. public function getContents($originUrl, $fileUrl, $progress = true, $options = array())
  33800. {
  33801. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  33802. }
  33803. public function getOptions()
  33804. {
  33805. return $this->options;
  33806. }
  33807. public function setOptions(array $options)
  33808. {
  33809. $this->options = array_replace_recursive($this->options, $options);
  33810. }
  33811. public function isTlsDisabled()
  33812. {
  33813. return $this->disableTls === true;
  33814. }
  33815. public function getLastHeaders()
  33816. {
  33817. return $this->lastHeaders;
  33818. }
  33819. public static function findStatusCode(array $headers)
  33820. {
  33821. $value = null;
  33822. foreach ($headers as $header) {
  33823. if (preg_match('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  33824. $value = (int) $match[1];
  33825. }
  33826. }
  33827. return $value;
  33828. }
  33829. public function findStatusMessage(array $headers)
  33830. {
  33831. $value = null;
  33832. foreach ($headers as $header) {
  33833. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  33834. $value = $header;
  33835. }
  33836. }
  33837. return $value;
  33838. }
  33839. protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
  33840. {
  33841. $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
  33842. $this->bytesMax = 0;
  33843. $this->originUrl = $originUrl;
  33844. $this->fileUrl = $fileUrl;
  33845. $this->fileName = $fileName;
  33846. $this->progress = $progress;
  33847. $this->lastProgress = null;
  33848. $retryAuthFailure = true;
  33849. $this->lastHeaders = array();
  33850. $this->redirects = 1;
  33851. $tempAdditionalOptions = $additionalOptions;
  33852. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  33853. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  33854. unset($tempAdditionalOptions['retry-auth-failure']);
  33855. }
  33856. $isRedirect = false;
  33857. if (isset($tempAdditionalOptions['redirects'])) {
  33858. $this->redirects = $tempAdditionalOptions['redirects'];
  33859. $isRedirect = true;
  33860. unset($tempAdditionalOptions['redirects']);
  33861. }
  33862. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  33863. unset($tempAdditionalOptions);
  33864. $origFileUrl = $fileUrl;
  33865. if (isset($options['gitlab-token'])) {
  33866. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  33867. unset($options['gitlab-token']);
  33868. }
  33869. if (isset($options['http'])) {
  33870. $options['http']['ignore_errors'] = true;
  33871. }
  33872. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  33873. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  33874. $degradedPackagist = true;
  33875. }
  33876. $maxFileSize = null;
  33877. if (isset($options['max_file_size'])) {
  33878. $maxFileSize = $options['max_file_size'];
  33879. unset($options['max_file_size']);
  33880. }
  33881. $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
  33882. $proxy = $this->proxyManager->getProxyForRequest($fileUrl);
  33883. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  33884. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  33885. unset($origFileUrl, $proxy, $usingProxy);
  33886. if ((!preg_match('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist)) {
  33887. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  33888. }
  33889. if ($this->progress && !$isRedirect) {
  33890. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  33891. }
  33892. $errorMessage = '';
  33893. $errorCode = 0;
  33894. $result = false;
  33895. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  33896. if ($errorMessage) {
  33897. $errorMessage .= "\n";
  33898. }
  33899. $errorMessage .= preg_replace('{^file_get_contents\(.*?\): }', '', $msg);
  33900. return true;
  33901. });
  33902. $http_response_header = array();
  33903. try {
  33904. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  33905. if (!empty($http_response_header[0])) {
  33906. $statusCode = self::findStatusCode($http_response_header);
  33907. if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  33908. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  33909. }
  33910. if (in_array($statusCode, array(401, 403)) && $retryAuthFailure) {
  33911. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  33912. }
  33913. }
  33914. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  33915. if ($contentLength && Platform::strlen($result) < $contentLength) {
  33916. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  33917. $e->setHeaders($http_response_header);
  33918. $e->setStatusCode(self::findStatusCode($http_response_header));
  33919. try {
  33920. $e->setResponse($this->decodeResult($result, $http_response_header));
  33921. } catch (\Exception $discarded) {
  33922. $e->setResponse($this->normalizeResult($result));
  33923. }
  33924. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  33925. throw $e;
  33926. }
  33927. if (PHP_VERSION_ID < 50600 && !empty($options['ssl']['peer_fingerprint'])) {
  33928. $params = stream_context_get_params($ctx);
  33929. $expectedPeerFingerprint = $options['ssl']['peer_fingerprint'];
  33930. $peerFingerprint = TlsHelper::getCertificateFingerprint($params['options']['ssl']['peer_certificate']);
  33931. if ($expectedPeerFingerprint !== $peerFingerprint) {
  33932. throw new TransportException('Peer fingerprint did not match');
  33933. }
  33934. }
  33935. } catch (\Exception $e) {
  33936. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  33937. $e->setHeaders($http_response_header);
  33938. $e->setStatusCode(self::findStatusCode($http_response_header));
  33939. }
  33940. if ($e instanceof TransportException && $result !== false) {
  33941. $e->setResponse($this->decodeResult($result, $http_response_header));
  33942. }
  33943. $result = false;
  33944. }
  33945. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  33946. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  33947. }
  33948. restore_error_handler();
  33949. if (isset($e) && !$this->retry) {
  33950. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  33951. $this->degradedMode = true;
  33952. $this->io->writeError('');
  33953. $this->io->writeError(array(
  33954. '<error>'.$e->getMessage().'</error>',
  33955. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  33956. ));
  33957. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  33958. }
  33959. throw $e;
  33960. }
  33961. $statusCode = null;
  33962. $contentType = null;
  33963. $locationHeader = null;
  33964. if (!empty($http_response_header[0])) {
  33965. $statusCode = self::findStatusCode($http_response_header);
  33966. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  33967. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  33968. }
  33969. if ($originUrl === 'bitbucket.org'
  33970. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  33971. && substr($fileUrl, -4) === '.zip'
  33972. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  33973. && $contentType && preg_match('{^text/html\b}i', $contentType)
  33974. ) {
  33975. $result = false;
  33976. if ($retryAuthFailure) {
  33977. $this->promptAuthAndRetry(401);
  33978. }
  33979. }
  33980. if ($statusCode === 404
  33981. && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  33982. && false !== strpos($fileUrl, 'archive.zip')
  33983. ) {
  33984. $result = false;
  33985. if ($retryAuthFailure) {
  33986. $this->promptAuthAndRetry(401);
  33987. }
  33988. }
  33989. $hasFollowedRedirect = false;
  33990. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  33991. $hasFollowedRedirect = true;
  33992. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  33993. }
  33994. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  33995. if (!$this->retry) {
  33996. if ($this->progress && !$isRedirect) {
  33997. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  33998. }
  33999. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  34000. $e->setHeaders($http_response_header);
  34001. $e->setResponse($this->decodeResult($result, $http_response_header));
  34002. $e->setStatusCode($statusCode);
  34003. throw $e;
  34004. }
  34005. $result = false;
  34006. }
  34007. if ($this->progress && !$this->retry && !$isRedirect) {
  34008. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  34009. }
  34010. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  34011. try {
  34012. $result = $this->decodeResult($result, $http_response_header);
  34013. } catch (\Exception $e) {
  34014. if ($this->degradedMode) {
  34015. throw $e;
  34016. }
  34017. $this->degradedMode = true;
  34018. $this->io->writeError(array(
  34019. '',
  34020. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  34021. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  34022. ));
  34023. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  34024. }
  34025. }
  34026. if (false !== $result && null !== $fileName && !$isRedirect) {
  34027. if ('' === $result) {
  34028. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  34029. }
  34030. $errorMessage = '';
  34031. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  34032. if ($errorMessage) {
  34033. $errorMessage .= "\n";
  34034. }
  34035. $errorMessage .= preg_replace('{^file_put_contents\(.*?\): }', '', $msg);
  34036. return true;
  34037. });
  34038. $result = (bool) file_put_contents($fileName, $result);
  34039. restore_error_handler();
  34040. if (false === $result) {
  34041. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  34042. }
  34043. }
  34044. if (false === $result && false !== strpos($errorMessage, 'Peer certificate') && PHP_VERSION_ID < 50600) {
  34045. if (CaBundle::isOpensslParseSafe()) {
  34046. $certDetails = $this->getCertificateCnAndFp($this->fileUrl, $options);
  34047. if ($certDetails) {
  34048. $this->peerCertificateMap[$this->getUrlAuthority($this->fileUrl)] = $certDetails;
  34049. $this->retry = true;
  34050. }
  34051. } else {
  34052. $this->io->writeError('');
  34053. $this->io->writeError(sprintf(
  34054. '<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
  34055. PHP_VERSION
  34056. ));
  34057. }
  34058. }
  34059. if ($this->retry) {
  34060. $this->retry = false;
  34061. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  34062. if ($this->storeAuth) {
  34063. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  34064. $this->storeAuth = false;
  34065. }
  34066. return $result;
  34067. }
  34068. if (false === $result) {
  34069. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  34070. if (!empty($http_response_header[0])) {
  34071. $e->setHeaders($http_response_header);
  34072. }
  34073. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  34074. $this->degradedMode = true;
  34075. $this->io->writeError('');
  34076. $this->io->writeError(array(
  34077. '<error>'.$e->getMessage().'</error>',
  34078. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  34079. ));
  34080. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  34081. }
  34082. throw $e;
  34083. }
  34084. if (!empty($http_response_header[0])) {
  34085. $this->lastHeaders = $http_response_header;
  34086. }
  34087. return $result;
  34088. }
  34089. protected function getRemoteContents($originUrl, $fileUrl, $context, array &$responseHeaders = null, $maxFileSize = null)
  34090. {
  34091. $result = false;
  34092. try {
  34093. $e = null;
  34094. if ($maxFileSize !== null) {
  34095. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  34096. } else {
  34097. $result = file_get_contents($fileUrl, false, $context);
  34098. }
  34099. } catch (\Exception $e) {
  34100. } catch (\Throwable $e) {
  34101. }
  34102. if ($maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  34103. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  34104. }
  34105. $responseHeaders = isset($http_response_header) ? $http_response_header : array();
  34106. if (null !== $e) {
  34107. throw $e;
  34108. }
  34109. return $result;
  34110. }
  34111. protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
  34112. {
  34113. switch ($notificationCode) {
  34114. case STREAM_NOTIFY_FAILURE:
  34115. if (400 === $messageCode) {
  34116. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  34117. }
  34118. break;
  34119. case STREAM_NOTIFY_FILE_SIZE_IS:
  34120. $this->bytesMax = $bytesMax;
  34121. break;
  34122. case STREAM_NOTIFY_PROGRESS:
  34123. if ($this->bytesMax > 0 && $this->progress) {
  34124. $progression = min(100, (int) round($bytesTransferred / $this->bytesMax * 100));
  34125. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  34126. $this->lastProgress = $progression;
  34127. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  34128. }
  34129. }
  34130. break;
  34131. default:
  34132. break;
  34133. }
  34134. }
  34135. protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = array())
  34136. {
  34137. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers);
  34138. $this->storeAuth = $result['storeAuth'];
  34139. $this->retry = $result['retry'];
  34140. if ($this->retry) {
  34141. throw new TransportException('RETRY');
  34142. }
  34143. }
  34144. protected function getOptionsForUrl($originUrl, $additionalOptions)
  34145. {
  34146. $tlsOptions = array();
  34147. if ($this->disableTls === false && PHP_VERSION_ID < 50600 && !stream_is_local($this->fileUrl)) {
  34148. $host = parse_url($this->fileUrl, PHP_URL_HOST);
  34149. if (PHP_VERSION_ID < 50304) {
  34150. if ($host === 'github.com' || $host === 'api.github.com') {
  34151. $host = '*.github.com';
  34152. }
  34153. }
  34154. $tlsOptions['ssl']['CN_match'] = $host;
  34155. $tlsOptions['ssl']['SNI_server_name'] = $host;
  34156. $urlAuthority = $this->getUrlAuthority($this->fileUrl);
  34157. if (isset($this->peerCertificateMap[$urlAuthority])) {
  34158. $certMap = $this->peerCertificateMap[$urlAuthority];
  34159. $this->io->writeError('', true, IOInterface::DEBUG);
  34160. $this->io->writeError(sprintf(
  34161. 'Using <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
  34162. $certMap['cn'],
  34163. $urlAuthority
  34164. ), true, IOInterface::DEBUG);
  34165. $tlsOptions['ssl']['CN_match'] = $certMap['cn'];
  34166. $tlsOptions['ssl']['peer_fingerprint'] = $certMap['fp'];
  34167. } elseif (!CaBundle::isOpensslParseSafe() && $host === 'repo.packagist.org') {
  34168. $tlsOptions['ssl']['CN_match'] = 'packagist.org';
  34169. }
  34170. }
  34171. $headers = array();
  34172. if (extension_loaded('zlib')) {
  34173. $headers[] = 'Accept-Encoding: gzip';
  34174. }
  34175. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  34176. if (!$this->degradedMode) {
  34177. $options['http']['protocol_version'] = 1.1;
  34178. $headers[] = 'Connection: close';
  34179. }
  34180. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  34181. $options['http']['follow_location'] = 0;
  34182. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  34183. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  34184. }
  34185. foreach ($headers as $header) {
  34186. $options['http']['header'][] = $header;
  34187. }
  34188. return $options;
  34189. }
  34190. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  34191. {
  34192. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  34193. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  34194. $targetUrl = $locationHeader;
  34195. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  34196. $targetUrl = $this->scheme.':'.$locationHeader;
  34197. } elseif ('/' === $locationHeader[0]) {
  34198. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  34199. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  34200. } else {
  34201. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  34202. }
  34203. }
  34204. if (!empty($targetUrl)) {
  34205. $this->redirects++;
  34206. $this->io->writeError('', true, IOInterface::DEBUG);
  34207. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  34208. $additionalOptions['redirects'] = $this->redirects;
  34209. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  34210. }
  34211. if (!$this->retry) {
  34212. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  34213. $e->setHeaders($http_response_header);
  34214. $e->setResponse($this->decodeResult($result, $http_response_header));
  34215. throw $e;
  34216. }
  34217. return false;
  34218. }
  34219. private function getCertificateCnAndFp($url, $options)
  34220. {
  34221. if (PHP_VERSION_ID >= 50600) {
  34222. throw new \BadMethodCallException(sprintf(
  34223. '%s must not be used on PHP >= 5.6',
  34224. __METHOD__
  34225. ));
  34226. }
  34227. $context = StreamContextFactory::getContext($url, $options, array('options' => array(
  34228. 'ssl' => array(
  34229. 'capture_peer_cert' => true,
  34230. 'verify_peer' => false,
  34231. ), ),
  34232. ));
  34233. if (false === $handle = @fopen($url, 'rb', false, $context)) {
  34234. return null;
  34235. }
  34236. fclose($handle);
  34237. $handle = null;
  34238. $params = stream_context_get_params($context);
  34239. if (!empty($params['options']['ssl']['peer_certificate'])) {
  34240. $peerCertificate = $params['options']['ssl']['peer_certificate'];
  34241. if (TlsHelper::checkCertificateHost($peerCertificate, parse_url($url, PHP_URL_HOST), $commonName)) {
  34242. return array(
  34243. 'cn' => $commonName,
  34244. 'fp' => TlsHelper::getCertificateFingerprint($peerCertificate),
  34245. );
  34246. }
  34247. }
  34248. return null;
  34249. }
  34250. private function getUrlAuthority($url)
  34251. {
  34252. $defaultPorts = array(
  34253. 'ftp' => 21,
  34254. 'http' => 80,
  34255. 'https' => 443,
  34256. 'ssh2.sftp' => 22,
  34257. 'ssh2.scp' => 22,
  34258. );
  34259. $scheme = parse_url($url, PHP_URL_SCHEME);
  34260. if (!isset($defaultPorts[$scheme])) {
  34261. throw new \InvalidArgumentException(sprintf(
  34262. 'Could not get default port for unknown scheme: %s',
  34263. $scheme
  34264. ));
  34265. }
  34266. $defaultPort = $defaultPorts[$scheme];
  34267. $port = parse_url($url, PHP_URL_PORT) ?: $defaultPort;
  34268. return parse_url($url, PHP_URL_HOST).':'.$port;
  34269. }
  34270. private function decodeResult($result, $http_response_header)
  34271. {
  34272. if ($result && extension_loaded('zlib')) {
  34273. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  34274. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  34275. if ($decode) {
  34276. if (PHP_VERSION_ID >= 50400) {
  34277. $result = zlib_decode($result);
  34278. } else {
  34279. $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result));
  34280. }
  34281. if ($result === false) {
  34282. throw new TransportException('Failed to decode zlib stream');
  34283. }
  34284. }
  34285. }
  34286. return $this->normalizeResult($result);
  34287. }
  34288. private function normalizeResult($result)
  34289. {
  34290. if ($result === false) {
  34291. return null;
  34292. }
  34293. return $result;
  34294. }
  34295. }
  34296. <?php
  34297. namespace Composer\Util;
  34298. class Silencer
  34299. {
  34300. private static $stack = array();
  34301. public static function suppress($mask = null)
  34302. {
  34303. if (!isset($mask)) {
  34304. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  34305. }
  34306. $old = error_reporting();
  34307. self::$stack[] = $old;
  34308. error_reporting($old & ~$mask);
  34309. return $old;
  34310. }
  34311. public static function restore()
  34312. {
  34313. if (!empty(self::$stack)) {
  34314. error_reporting(array_pop(self::$stack));
  34315. }
  34316. }
  34317. public static function call($callable )
  34318. {
  34319. try {
  34320. self::suppress();
  34321. $result = call_user_func_array($callable, array_slice(func_get_args(), 1));
  34322. self::restore();
  34323. return $result;
  34324. } catch (\Exception $e) {
  34325. self::restore();
  34326. throw $e;
  34327. }
  34328. }
  34329. }
  34330. <?php
  34331. namespace Composer\Util;
  34332. use Composer\Composer;
  34333. use Composer\CaBundle\CaBundle;
  34334. use Composer\Downloader\TransportException;
  34335. use Composer\Repository\PlatformRepository;
  34336. use Composer\Util\Http\ProxyManager;
  34337. use Psr\Log\LoggerInterface;
  34338. final class StreamContextFactory
  34339. {
  34340. public static function getContext($url, array $defaultOptions = array(), array $defaultParams = array())
  34341. {
  34342. $options = array('http' => array(
  34343. 'follow_location' => 1,
  34344. 'max_redirects' => 20,
  34345. ));
  34346. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  34347. unset($defaultOptions['http']['header']);
  34348. $options = array_replace_recursive($options, $defaultOptions);
  34349. if (isset($options['http']['header'])) {
  34350. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  34351. }
  34352. return stream_context_create($options, $defaultParams);
  34353. }
  34354. public static function initOptions($url, array $options, $forCurl = false)
  34355. {
  34356. if (!isset($options['http']['header'])) {
  34357. $options['http']['header'] = array();
  34358. }
  34359. if (is_string($options['http']['header'])) {
  34360. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  34361. }
  34362. if (!$forCurl) {
  34363. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  34364. if ($proxyOptions = $proxy->getContextOptions()) {
  34365. $isHttpsRequest = 0 === strpos($url, 'https://');
  34366. if ($proxy->isSecure()) {
  34367. if (!extension_loaded('openssl')) {
  34368. throw new TransportException('You must enable the openssl extension to use a secure proxy.');
  34369. }
  34370. if ($isHttpsRequest) {
  34371. throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
  34372. }
  34373. } elseif ($isHttpsRequest && !extension_loaded('openssl')) {
  34374. throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
  34375. }
  34376. if (isset($proxyOptions['http']['header'])) {
  34377. $options['http']['header'][] = $proxyOptions['http']['header'];
  34378. unset($proxyOptions['http']['header']);
  34379. }
  34380. $options = array_replace_recursive($options, $proxyOptions);
  34381. }
  34382. }
  34383. if (defined('HHVM_VERSION')) {
  34384. $phpVersion = 'HHVM ' . HHVM_VERSION;
  34385. } else {
  34386. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  34387. }
  34388. if ($forCurl) {
  34389. $curl = curl_version();
  34390. $httpVersion = 'cURL '.$curl['version'];
  34391. } else {
  34392. $httpVersion = 'streams';
  34393. }
  34394. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  34395. $platformPhpVersion = PlatformRepository::getPlatformPhpVersion();
  34396. $options['http']['header'][] = sprintf(
  34397. 'User-Agent: Composer/%s (%s; %s; %s; %s%s%s)',
  34398. Composer::getVersion(),
  34399. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  34400. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  34401. $phpVersion,
  34402. $httpVersion,
  34403. $platformPhpVersion ? '; Platform-PHP '.$platformPhpVersion : '',
  34404. getenv('CI') ? '; CI' : ''
  34405. );
  34406. }
  34407. return $options;
  34408. }
  34409. public static function getTlsDefaults(array $options, LoggerInterface $logger = null)
  34410. {
  34411. $ciphers = implode(':', array(
  34412. 'ECDHE-RSA-AES128-GCM-SHA256',
  34413. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  34414. 'ECDHE-RSA-AES256-GCM-SHA384',
  34415. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  34416. 'DHE-RSA-AES128-GCM-SHA256',
  34417. 'DHE-DSS-AES128-GCM-SHA256',
  34418. 'kEDH+AESGCM',
  34419. 'ECDHE-RSA-AES128-SHA256',
  34420. 'ECDHE-ECDSA-AES128-SHA256',
  34421. 'ECDHE-RSA-AES128-SHA',
  34422. 'ECDHE-ECDSA-AES128-SHA',
  34423. 'ECDHE-RSA-AES256-SHA384',
  34424. 'ECDHE-ECDSA-AES256-SHA384',
  34425. 'ECDHE-RSA-AES256-SHA',
  34426. 'ECDHE-ECDSA-AES256-SHA',
  34427. 'DHE-RSA-AES128-SHA256',
  34428. 'DHE-RSA-AES128-SHA',
  34429. 'DHE-DSS-AES128-SHA256',
  34430. 'DHE-RSA-AES256-SHA256',
  34431. 'DHE-DSS-AES256-SHA',
  34432. 'DHE-RSA-AES256-SHA',
  34433. 'AES128-GCM-SHA256',
  34434. 'AES256-GCM-SHA384',
  34435. 'AES128-SHA256',
  34436. 'AES256-SHA256',
  34437. 'AES128-SHA',
  34438. 'AES256-SHA',
  34439. 'AES',
  34440. 'CAMELLIA',
  34441. 'DES-CBC3-SHA',
  34442. '!aNULL',
  34443. '!eNULL',
  34444. '!EXPORT',
  34445. '!DES',
  34446. '!RC4',
  34447. '!MD5',
  34448. '!PSK',
  34449. '!aECDH',
  34450. '!EDH-DSS-DES-CBC3-SHA',
  34451. '!EDH-RSA-DES-CBC3-SHA',
  34452. '!KRB5-DES-CBC3-SHA',
  34453. ));
  34454. $defaults = array(
  34455. 'ssl' => array(
  34456. 'ciphers' => $ciphers,
  34457. 'verify_peer' => true,
  34458. 'verify_depth' => 7,
  34459. 'SNI_enabled' => true,
  34460. 'capture_peer_cert' => true,
  34461. ),
  34462. );
  34463. if (isset($options['ssl'])) {
  34464. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  34465. }
  34466. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  34467. $result = CaBundle::getSystemCaRootBundlePath($logger);
  34468. if (is_dir($result)) {
  34469. $defaults['ssl']['capath'] = $result;
  34470. } else {
  34471. $defaults['ssl']['cafile'] = $result;
  34472. }
  34473. }
  34474. if (isset($defaults['ssl']['cafile']) && (!Filesystem::isReadable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  34475. throw new TransportException('The configured cafile was not valid or could not be read.');
  34476. }
  34477. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !Filesystem::isReadable($defaults['ssl']['capath']))) {
  34478. throw new TransportException('The configured capath was not valid or could not be read.');
  34479. }
  34480. if (PHP_VERSION_ID >= 50413) {
  34481. $defaults['ssl']['disable_compression'] = true;
  34482. }
  34483. return $defaults;
  34484. }
  34485. private static function fixHttpHeaderField($header)
  34486. {
  34487. if (!is_array($header)) {
  34488. $header = explode("\r\n", $header);
  34489. }
  34490. uasort($header, function ($el) {
  34491. return stripos($el, 'content-type') === 0 ? 1 : -1;
  34492. });
  34493. return $header;
  34494. }
  34495. }
  34496. <?php
  34497. namespace Composer\Util;
  34498. use Composer\Config;
  34499. use Composer\IO\IOInterface;
  34500. class Svn
  34501. {
  34502. const MAX_QTY_AUTH_TRIES = 5;
  34503. protected $credentials;
  34504. protected $hasAuth;
  34505. protected $io;
  34506. protected $url;
  34507. protected $cacheCredentials = true;
  34508. protected $process;
  34509. protected $qtyAuthTries = 0;
  34510. protected $config;
  34511. private static $version;
  34512. public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null)
  34513. {
  34514. $this->url = $url;
  34515. $this->io = $io;
  34516. $this->config = $config;
  34517. $this->process = $process ?: new ProcessExecutor($io);
  34518. }
  34519. public static function cleanEnv()
  34520. {
  34521. Platform::clearEnv('DYLD_LIBRARY_PATH');
  34522. }
  34523. public function execute($command, $url, $cwd = null, $path = null, $verbose = false)
  34524. {
  34525. $this->config->prohibitUrlByConfig($url, $this->io);
  34526. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  34527. }
  34528. public function executeLocal($command, $path, $cwd = null, $verbose = false)
  34529. {
  34530. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  34531. }
  34532. private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
  34533. {
  34534. $command = $this->getCommand($svnCommand, $url, $path);
  34535. $output = null;
  34536. $io = $this->io;
  34537. $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
  34538. if ($type !== 'out') {
  34539. return null;
  34540. }
  34541. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  34542. return null;
  34543. }
  34544. $output .= $buffer;
  34545. if ($verbose) {
  34546. $io->writeError($buffer, false);
  34547. }
  34548. };
  34549. $status = $this->process->execute($command, $handler, $cwd);
  34550. if (0 === $status) {
  34551. return $output;
  34552. }
  34553. $errorOutput = $this->process->getErrorOutput();
  34554. $fullOutput = implode("\n", array($output, $errorOutput));
  34555. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  34556. && false === stripos($fullOutput, 'authorization failed')
  34557. && false === stripos($fullOutput, 'svn: E170001:')
  34558. && false === stripos($fullOutput, 'svn: E215004:')) {
  34559. throw new \RuntimeException($fullOutput);
  34560. }
  34561. if (!$this->hasAuth()) {
  34562. $this->doAuthDance();
  34563. }
  34564. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  34565. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  34566. }
  34567. throw new \RuntimeException(
  34568. 'wrong credentials provided ('.$fullOutput.')'
  34569. );
  34570. }
  34571. public function setCacheCredentials($cacheCredentials)
  34572. {
  34573. $this->cacheCredentials = $cacheCredentials;
  34574. }
  34575. protected function doAuthDance()
  34576. {
  34577. if (!$this->io->isInteractive()) {
  34578. throw new \RuntimeException(
  34579. 'can not ask for authentication in non interactive mode'
  34580. );
  34581. }
  34582. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  34583. $this->hasAuth = true;
  34584. $this->credentials['username'] = $this->io->ask("Username: ");
  34585. $this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
  34586. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  34587. return $this;
  34588. }
  34589. protected function getCommand($cmd, $url, $path = null)
  34590. {
  34591. $cmd = sprintf(
  34592. '%s %s%s -- %s',
  34593. $cmd,
  34594. '--non-interactive ',
  34595. $this->getCredentialString(),
  34596. ProcessExecutor::escape($url)
  34597. );
  34598. if ($path) {
  34599. $cmd .= ' ' . ProcessExecutor::escape($path);
  34600. }
  34601. return $cmd;
  34602. }
  34603. protected function getCredentialString()
  34604. {
  34605. if (!$this->hasAuth()) {
  34606. return '';
  34607. }
  34608. return sprintf(
  34609. ' %s--username %s --password %s ',
  34610. $this->getAuthCache(),
  34611. ProcessExecutor::escape($this->getUsername()),
  34612. ProcessExecutor::escape($this->getPassword())
  34613. );
  34614. }
  34615. protected function getPassword()
  34616. {
  34617. if ($this->credentials === null) {
  34618. throw new \LogicException("No svn auth detected.");
  34619. }
  34620. return isset($this->credentials['password']) ? $this->credentials['password'] : '';
  34621. }
  34622. protected function getUsername()
  34623. {
  34624. if ($this->credentials === null) {
  34625. throw new \LogicException("No svn auth detected.");
  34626. }
  34627. return $this->credentials['username'];
  34628. }
  34629. protected function hasAuth()
  34630. {
  34631. if (null !== $this->hasAuth) {
  34632. return $this->hasAuth;
  34633. }
  34634. if (false === $this->createAuthFromConfig()) {
  34635. $this->createAuthFromUrl();
  34636. }
  34637. return (bool) $this->hasAuth;
  34638. }
  34639. protected function getAuthCache()
  34640. {
  34641. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  34642. }
  34643. private function createAuthFromConfig()
  34644. {
  34645. if (!$this->config->has('http-basic')) {
  34646. return $this->hasAuth = false;
  34647. }
  34648. $authConfig = $this->config->get('http-basic');
  34649. $host = parse_url($this->url, PHP_URL_HOST);
  34650. if (isset($authConfig[$host])) {
  34651. $this->credentials['username'] = $authConfig[$host]['username'];
  34652. $this->credentials['password'] = $authConfig[$host]['password'];
  34653. return $this->hasAuth = true;
  34654. }
  34655. return $this->hasAuth = false;
  34656. }
  34657. private function createAuthFromUrl()
  34658. {
  34659. $uri = parse_url($this->url);
  34660. if (empty($uri['user'])) {
  34661. return $this->hasAuth = false;
  34662. }
  34663. $this->credentials['username'] = $uri['user'];
  34664. if (!empty($uri['pass'])) {
  34665. $this->credentials['password'] = $uri['pass'];
  34666. }
  34667. return $this->hasAuth = true;
  34668. }
  34669. public function binaryVersion()
  34670. {
  34671. if (!self::$version) {
  34672. if (0 === $this->process->execute('svn --version', $output)) {
  34673. if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match)) {
  34674. self::$version = $match[1];
  34675. }
  34676. }
  34677. }
  34678. return self::$version;
  34679. }
  34680. }
  34681. <?php
  34682. namespace Composer\Util;
  34683. use Composer\Downloader\DownloaderInterface;
  34684. use Composer\Package\PackageInterface;
  34685. use React\Promise\PromiseInterface;
  34686. class SyncHelper
  34687. {
  34688. public static function downloadAndInstallPackageSync(Loop $loop, DownloaderInterface $downloader, $path, PackageInterface $package, PackageInterface $prevPackage = null)
  34689. {
  34690. $type = $prevPackage ? 'update' : 'install';
  34691. try {
  34692. self::await($loop, $downloader->download($package, $path, $prevPackage));
  34693. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  34694. if ($type === 'update') {
  34695. self::await($loop, $downloader->update($package, $prevPackage, $path));
  34696. } else {
  34697. self::await($loop, $downloader->install($package, $path));
  34698. }
  34699. } catch (\Exception $e) {
  34700. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  34701. throw $e;
  34702. }
  34703. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  34704. }
  34705. public static function await(Loop $loop, PromiseInterface $promise = null)
  34706. {
  34707. if ($promise) {
  34708. $loop->wait(array($promise));
  34709. }
  34710. }
  34711. }
  34712. <?php
  34713. namespace Composer\Util;
  34714. class Tar
  34715. {
  34716. public static function getComposerJson($pathToArchive)
  34717. {
  34718. $phar = new \PharData($pathToArchive);
  34719. if (!$phar->valid()) {
  34720. return null;
  34721. }
  34722. return self::extractComposerJsonFromFolder($phar);
  34723. }
  34724. private static function extractComposerJsonFromFolder(\PharData $phar)
  34725. {
  34726. if (isset($phar['composer.json'])) {
  34727. return $phar['composer.json']->getContent();
  34728. }
  34729. $topLevelPaths = array();
  34730. foreach ($phar as $folderFile) {
  34731. $name = $folderFile->getBasename();
  34732. if ($folderFile->isDir()) {
  34733. $topLevelPaths[$name] = true;
  34734. if (\count($topLevelPaths) > 1) {
  34735. 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)));
  34736. }
  34737. }
  34738. }
  34739. $composerJsonPath = key($topLevelPaths).'/composer.json';
  34740. if ($topLevelPaths && isset($phar[$composerJsonPath])) {
  34741. return $phar[$composerJsonPath]->getContent();
  34742. }
  34743. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  34744. }
  34745. }
  34746. <?php
  34747. namespace Composer\Util;
  34748. use Composer\CaBundle\CaBundle;
  34749. final class TlsHelper
  34750. {
  34751. public static function checkCertificateHost($certificate, $hostname, &$cn = null)
  34752. {
  34753. $names = self::getCertificateNames($certificate);
  34754. if (empty($names)) {
  34755. return false;
  34756. }
  34757. $combinedNames = array_merge($names['san'], array($names['cn']));
  34758. $hostname = strtolower($hostname);
  34759. foreach ($combinedNames as $certName) {
  34760. $matcher = self::certNameMatcher($certName);
  34761. if ($matcher && $matcher($hostname)) {
  34762. $cn = $names['cn'];
  34763. return true;
  34764. }
  34765. }
  34766. return false;
  34767. }
  34768. public static function getCertificateNames($certificate)
  34769. {
  34770. if (is_array($certificate)) {
  34771. $info = $certificate;
  34772. } elseif (CaBundle::isOpensslParseSafe()) {
  34773. $info = openssl_x509_parse($certificate, false);
  34774. }
  34775. if (!isset($info['subject']['commonName'])) {
  34776. return null;
  34777. }
  34778. $commonName = strtolower($info['subject']['commonName']);
  34779. $subjectAltNames = array();
  34780. if (isset($info['extensions']['subjectAltName'])) {
  34781. $subjectAltNames = preg_split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  34782. $subjectAltNames = array_filter(array_map(function ($name) {
  34783. if (0 === strpos($name, 'DNS:')) {
  34784. return strtolower(ltrim(substr($name, 4)));
  34785. }
  34786. return null;
  34787. }, $subjectAltNames));
  34788. $subjectAltNames = array_values($subjectAltNames);
  34789. }
  34790. return array(
  34791. 'cn' => $commonName,
  34792. 'san' => $subjectAltNames,
  34793. );
  34794. }
  34795. public static function getCertificateFingerprint($certificate)
  34796. {
  34797. $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
  34798. $pubkeypem = $pubkeydetails['key'];
  34799. $start = '-----BEGIN PUBLIC KEY-----';
  34800. $end = '-----END PUBLIC KEY-----';
  34801. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  34802. $der = base64_decode($pemtrim);
  34803. return sha1($der);
  34804. }
  34805. public static function isOpensslParseSafe()
  34806. {
  34807. return CaBundle::isOpensslParseSafe();
  34808. }
  34809. private static function certNameMatcher($certName)
  34810. {
  34811. $wildcards = substr_count($certName, '*');
  34812. if (0 === $wildcards) {
  34813. return function ($hostname) use ($certName) {
  34814. return $hostname === $certName;
  34815. };
  34816. }
  34817. if (1 === $wildcards) {
  34818. $components = explode('.', $certName);
  34819. if (3 > count($components)) {
  34820. return null;
  34821. }
  34822. $firstComponent = $components[0];
  34823. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  34824. return null;
  34825. }
  34826. $wildcardRegex = preg_quote($certName);
  34827. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  34828. $wildcardRegex = "{^{$wildcardRegex}$}";
  34829. return function ($hostname) use ($wildcardRegex) {
  34830. return 1 === preg_match($wildcardRegex, $hostname);
  34831. };
  34832. }
  34833. return null;
  34834. }
  34835. }
  34836. <?php
  34837. namespace Composer\Util;
  34838. use Composer\Config;
  34839. class Url
  34840. {
  34841. public static function updateDistReference(Config $config, $url, $ref)
  34842. {
  34843. $host = parse_url($url, PHP_URL_HOST);
  34844. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  34845. if (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  34846. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  34847. } elseif (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  34848. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  34849. } elseif (preg_match('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  34850. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  34851. }
  34852. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  34853. if (preg_match('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  34854. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  34855. }
  34856. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  34857. if (preg_match('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  34858. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  34859. }
  34860. } elseif (in_array($host, $config->get('github-domains'), true)) {
  34861. $url = preg_replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  34862. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  34863. $url = preg_replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  34864. }
  34865. return $url;
  34866. }
  34867. public static function getOrigin(Config $config, $url)
  34868. {
  34869. if (0 === strpos($url, 'file://')) {
  34870. return $url;
  34871. }
  34872. $origin = (string) parse_url($url, PHP_URL_HOST);
  34873. if ($port = parse_url($url, PHP_URL_PORT)) {
  34874. $origin .= ':'.$port;
  34875. }
  34876. if (strpos($origin, '.github.com') === (strlen($origin) - 11)) {
  34877. return 'github.com';
  34878. }
  34879. if ($origin === 'repo.packagist.org') {
  34880. return 'packagist.org';
  34881. }
  34882. if ($origin === '') {
  34883. $origin = $url;
  34884. }
  34885. if (
  34886. is_array($config->get('gitlab-domains'))
  34887. && false === strpos($origin, '/')
  34888. && !in_array($origin, $config->get('gitlab-domains'))
  34889. ) {
  34890. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  34891. if (0 === strpos($gitlabDomain, $origin)) {
  34892. return $gitlabDomain;
  34893. }
  34894. }
  34895. }
  34896. return $origin;
  34897. }
  34898. public static function sanitize($url)
  34899. {
  34900. $url = preg_replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  34901. $url = preg_replace_callback('{^(?P<prefix>[a-z0-9]+://)?(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  34902. if (preg_match('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  34903. return $m['prefix'].'***:***@';
  34904. }
  34905. return $m['prefix'].$m['user'].':***@';
  34906. }, $url);
  34907. return $url;
  34908. }
  34909. }
  34910. <?php
  34911. namespace Composer\Util;
  34912. class Zip
  34913. {
  34914. public static function getComposerJson($pathToZip)
  34915. {
  34916. if (!extension_loaded('zip')) {
  34917. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  34918. }
  34919. $zip = new \ZipArchive();
  34920. if ($zip->open($pathToZip) !== true) {
  34921. return null;
  34922. }
  34923. if (0 == $zip->numFiles) {
  34924. $zip->close();
  34925. return null;
  34926. }
  34927. $foundFileIndex = self::locateFile($zip, 'composer.json');
  34928. $content = null;
  34929. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  34930. $stream = $zip->getStream($configurationFileName);
  34931. if (false !== $stream) {
  34932. $content = stream_get_contents($stream);
  34933. }
  34934. $zip->close();
  34935. return $content;
  34936. }
  34937. private static function locateFile(\ZipArchive $zip, $filename)
  34938. {
  34939. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  34940. return $index;
  34941. }
  34942. $topLevelPaths = array();
  34943. for ($i = 0; $i < $zip->numFiles; $i++) {
  34944. $name = $zip->getNameIndex($i);
  34945. $dirname = dirname($name);
  34946. if (strpos($name, '__MACOSX') !== false) {
  34947. continue;
  34948. }
  34949. if ($dirname === '.') {
  34950. $topLevelPaths[$name] = true;
  34951. if (\count($topLevelPaths) > 1) {
  34952. 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)));
  34953. }
  34954. continue;
  34955. }
  34956. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  34957. $topLevelPaths[$dirname.'/'] = true;
  34958. if (\count($topLevelPaths) > 1) {
  34959. 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)));
  34960. }
  34961. }
  34962. }
  34963. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  34964. return $index;
  34965. }
  34966. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  34967. }
  34968. }
  34969. <?php
  34970. function includeIfExists($file)
  34971. {
  34972. return file_exists($file) ? include $file : null;
  34973. }
  34974. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  34975. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  34976. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  34977. exit(1);
  34978. }
  34979. return $loader;
  34980. <?php
  34981. /*
  34982. * This file is part of Composer.
  34983. *
  34984. * (c) Nils Adermann <naderman@naderman.de>
  34985. * Jordi Boggiano <j.boggiano@seld.be>
  34986. *
  34987. * For the full copyright and license information, please view the LICENSE
  34988. * file that was distributed with this source code.
  34989. */
  34990. namespace Composer\Autoload;
  34991. /**
  34992. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  34993. *
  34994. * $loader = new \Composer\Autoload\ClassLoader();
  34995. *
  34996. * // register classes with namespaces
  34997. * $loader->add('Symfony\Component', __DIR__.'/component');
  34998. * $loader->add('Symfony', __DIR__.'/framework');
  34999. *
  35000. * // activate the autoloader
  35001. * $loader->register();
  35002. *
  35003. * // to enable searching the include path (eg. for PEAR packages)
  35004. * $loader->setUseIncludePath(true);
  35005. *
  35006. * In this example, if you try to use a class in the Symfony\Component
  35007. * namespace or one of its children (Symfony\Component\Console for instance),
  35008. * the autoloader will first look for the class under the component/
  35009. * directory, and it will then fallback to the framework/ directory if not
  35010. * found before giving up.
  35011. *
  35012. * This class is loosely based on the Symfony UniversalClassLoader.
  35013. *
  35014. * @author Fabien Potencier <fabien@symfony.com>
  35015. * @author Jordi Boggiano <j.boggiano@seld.be>
  35016. * @see https://www.php-fig.org/psr/psr-0/
  35017. * @see https://www.php-fig.org/psr/psr-4/
  35018. */
  35019. class ClassLoader
  35020. {
  35021. /** @var ?string */
  35022. private $vendorDir;
  35023. // PSR-4
  35024. /**
  35025. * @var array[]
  35026. * @psalm-var array<string, array<string, int>>
  35027. */
  35028. private $prefixLengthsPsr4 = array();
  35029. /**
  35030. * @var array[]
  35031. * @psalm-var array<string, array<int, string>>
  35032. */
  35033. private $prefixDirsPsr4 = array();
  35034. /**
  35035. * @var array[]
  35036. * @psalm-var array<string, string>
  35037. */
  35038. private $fallbackDirsPsr4 = array();
  35039. // PSR-0
  35040. /**
  35041. * @var array[]
  35042. * @psalm-var array<string, array<string, string[]>>
  35043. */
  35044. private $prefixesPsr0 = array();
  35045. /**
  35046. * @var array[]
  35047. * @psalm-var array<string, string>
  35048. */
  35049. private $fallbackDirsPsr0 = array();
  35050. /** @var bool */
  35051. private $useIncludePath = false;
  35052. /**
  35053. * @var string[]
  35054. * @psalm-var array<string, string>
  35055. */
  35056. private $classMap = array();
  35057. /** @var bool */
  35058. private $classMapAuthoritative = false;
  35059. /**
  35060. * @var bool[]
  35061. * @psalm-var array<string, bool>
  35062. */
  35063. private $missingClasses = array();
  35064. /** @var ?string */
  35065. private $apcuPrefix;
  35066. /**
  35067. * @var self[]
  35068. */
  35069. private static $registeredLoaders = array();
  35070. /**
  35071. * @param ?string $vendorDir
  35072. */
  35073. public function __construct($vendorDir = null)
  35074. {
  35075. $this->vendorDir = $vendorDir;
  35076. }
  35077. /**
  35078. * @return string[]
  35079. */
  35080. public function getPrefixes()
  35081. {
  35082. if (!empty($this->prefixesPsr0)) {
  35083. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  35084. }
  35085. return array();
  35086. }
  35087. /**
  35088. * @return array[]
  35089. * @psalm-return array<string, array<int, string>>
  35090. */
  35091. public function getPrefixesPsr4()
  35092. {
  35093. return $this->prefixDirsPsr4;
  35094. }
  35095. /**
  35096. * @return array[]
  35097. * @psalm-return array<string, string>
  35098. */
  35099. public function getFallbackDirs()
  35100. {
  35101. return $this->fallbackDirsPsr0;
  35102. }
  35103. /**
  35104. * @return array[]
  35105. * @psalm-return array<string, string>
  35106. */
  35107. public function getFallbackDirsPsr4()
  35108. {
  35109. return $this->fallbackDirsPsr4;
  35110. }
  35111. /**
  35112. * @return string[] Array of classname => path
  35113. * @psalm-var array<string, string>
  35114. */
  35115. public function getClassMap()
  35116. {
  35117. return $this->classMap;
  35118. }
  35119. /**
  35120. * @param string[] $classMap Class to filename map
  35121. * @psalm-param array<string, string> $classMap
  35122. *
  35123. * @return void
  35124. */
  35125. public function addClassMap(array $classMap)
  35126. {
  35127. if ($this->classMap) {
  35128. $this->classMap = array_merge($this->classMap, $classMap);
  35129. } else {
  35130. $this->classMap = $classMap;
  35131. }
  35132. }
  35133. /**
  35134. * Registers a set of PSR-0 directories for a given prefix, either
  35135. * appending or prepending to the ones previously set for this prefix.
  35136. *
  35137. * @param string $prefix The prefix
  35138. * @param string[]|string $paths The PSR-0 root directories
  35139. * @param bool $prepend Whether to prepend the directories
  35140. *
  35141. * @return void
  35142. */
  35143. public function add($prefix, $paths, $prepend = false)
  35144. {
  35145. if (!$prefix) {
  35146. if ($prepend) {
  35147. $this->fallbackDirsPsr0 = array_merge(
  35148. (array) $paths,
  35149. $this->fallbackDirsPsr0
  35150. );
  35151. } else {
  35152. $this->fallbackDirsPsr0 = array_merge(
  35153. $this->fallbackDirsPsr0,
  35154. (array) $paths
  35155. );
  35156. }
  35157. return;
  35158. }
  35159. $first = $prefix[0];
  35160. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  35161. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  35162. return;
  35163. }
  35164. if ($prepend) {
  35165. $this->prefixesPsr0[$first][$prefix] = array_merge(
  35166. (array) $paths,
  35167. $this->prefixesPsr0[$first][$prefix]
  35168. );
  35169. } else {
  35170. $this->prefixesPsr0[$first][$prefix] = array_merge(
  35171. $this->prefixesPsr0[$first][$prefix],
  35172. (array) $paths
  35173. );
  35174. }
  35175. }
  35176. /**
  35177. * Registers a set of PSR-4 directories for a given namespace, either
  35178. * appending or prepending to the ones previously set for this namespace.
  35179. *
  35180. * @param string $prefix The prefix/namespace, with trailing '\\'
  35181. * @param string[]|string $paths The PSR-4 base directories
  35182. * @param bool $prepend Whether to prepend the directories
  35183. *
  35184. * @throws \InvalidArgumentException
  35185. *
  35186. * @return void
  35187. */
  35188. public function addPsr4($prefix, $paths, $prepend = false)
  35189. {
  35190. if (!$prefix) {
  35191. // Register directories for the root namespace.
  35192. if ($prepend) {
  35193. $this->fallbackDirsPsr4 = array_merge(
  35194. (array) $paths,
  35195. $this->fallbackDirsPsr4
  35196. );
  35197. } else {
  35198. $this->fallbackDirsPsr4 = array_merge(
  35199. $this->fallbackDirsPsr4,
  35200. (array) $paths
  35201. );
  35202. }
  35203. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  35204. // Register directories for a new namespace.
  35205. $length = strlen($prefix);
  35206. if ('\\' !== $prefix[$length - 1]) {
  35207. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  35208. }
  35209. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  35210. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  35211. } elseif ($prepend) {
  35212. // Prepend directories for an already registered namespace.
  35213. $this->prefixDirsPsr4[$prefix] = array_merge(
  35214. (array) $paths,
  35215. $this->prefixDirsPsr4[$prefix]
  35216. );
  35217. } else {
  35218. // Append directories for an already registered namespace.
  35219. $this->prefixDirsPsr4[$prefix] = array_merge(
  35220. $this->prefixDirsPsr4[$prefix],
  35221. (array) $paths
  35222. );
  35223. }
  35224. }
  35225. /**
  35226. * Registers a set of PSR-0 directories for a given prefix,
  35227. * replacing any others previously set for this prefix.
  35228. *
  35229. * @param string $prefix The prefix
  35230. * @param string[]|string $paths The PSR-0 base directories
  35231. *
  35232. * @return void
  35233. */
  35234. public function set($prefix, $paths)
  35235. {
  35236. if (!$prefix) {
  35237. $this->fallbackDirsPsr0 = (array) $paths;
  35238. } else {
  35239. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  35240. }
  35241. }
  35242. /**
  35243. * Registers a set of PSR-4 directories for a given namespace,
  35244. * replacing any others previously set for this namespace.
  35245. *
  35246. * @param string $prefix The prefix/namespace, with trailing '\\'
  35247. * @param string[]|string $paths The PSR-4 base directories
  35248. *
  35249. * @throws \InvalidArgumentException
  35250. *
  35251. * @return void
  35252. */
  35253. public function setPsr4($prefix, $paths)
  35254. {
  35255. if (!$prefix) {
  35256. $this->fallbackDirsPsr4 = (array) $paths;
  35257. } else {
  35258. $length = strlen($prefix);
  35259. if ('\\' !== $prefix[$length - 1]) {
  35260. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  35261. }
  35262. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  35263. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  35264. }
  35265. }
  35266. /**
  35267. * Turns on searching the include path for class files.
  35268. *
  35269. * @param bool $useIncludePath
  35270. *
  35271. * @return void
  35272. */
  35273. public function setUseIncludePath($useIncludePath)
  35274. {
  35275. $this->useIncludePath = $useIncludePath;
  35276. }
  35277. /**
  35278. * Can be used to check if the autoloader uses the include path to check
  35279. * for classes.
  35280. *
  35281. * @return bool
  35282. */
  35283. public function getUseIncludePath()
  35284. {
  35285. return $this->useIncludePath;
  35286. }
  35287. /**
  35288. * Turns off searching the prefix and fallback directories for classes
  35289. * that have not been registered with the class map.
  35290. *
  35291. * @param bool $classMapAuthoritative
  35292. *
  35293. * @return void
  35294. */
  35295. public function setClassMapAuthoritative($classMapAuthoritative)
  35296. {
  35297. $this->classMapAuthoritative = $classMapAuthoritative;
  35298. }
  35299. /**
  35300. * Should class lookup fail if not found in the current class map?
  35301. *
  35302. * @return bool
  35303. */
  35304. public function isClassMapAuthoritative()
  35305. {
  35306. return $this->classMapAuthoritative;
  35307. }
  35308. /**
  35309. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  35310. *
  35311. * @param string|null $apcuPrefix
  35312. *
  35313. * @return void
  35314. */
  35315. public function setApcuPrefix($apcuPrefix)
  35316. {
  35317. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  35318. }
  35319. /**
  35320. * The APCu prefix in use, or null if APCu caching is not enabled.
  35321. *
  35322. * @return string|null
  35323. */
  35324. public function getApcuPrefix()
  35325. {
  35326. return $this->apcuPrefix;
  35327. }
  35328. /**
  35329. * Registers this instance as an autoloader.
  35330. *
  35331. * @param bool $prepend Whether to prepend the autoloader or not
  35332. *
  35333. * @return void
  35334. */
  35335. public function register($prepend = false)
  35336. {
  35337. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  35338. if (null === $this->vendorDir) {
  35339. return;
  35340. }
  35341. if ($prepend) {
  35342. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  35343. } else {
  35344. unset(self::$registeredLoaders[$this->vendorDir]);
  35345. self::$registeredLoaders[$this->vendorDir] = $this;
  35346. }
  35347. }
  35348. /**
  35349. * Unregisters this instance as an autoloader.
  35350. *
  35351. * @return void
  35352. */
  35353. public function unregister()
  35354. {
  35355. spl_autoload_unregister(array($this, 'loadClass'));
  35356. if (null !== $this->vendorDir) {
  35357. unset(self::$registeredLoaders[$this->vendorDir]);
  35358. }
  35359. }
  35360. /**
  35361. * Loads the given class or interface.
  35362. *
  35363. * @param string $class The name of the class
  35364. * @return true|null True if loaded, null otherwise
  35365. */
  35366. public function loadClass($class)
  35367. {
  35368. if ($file = $this->findFile($class)) {
  35369. includeFile($file);
  35370. return true;
  35371. }
  35372. return null;
  35373. }
  35374. /**
  35375. * Finds the path to the file where the class is defined.
  35376. *
  35377. * @param string $class The name of the class
  35378. *
  35379. * @return string|false The path if found, false otherwise
  35380. */
  35381. public function findFile($class)
  35382. {
  35383. // class map lookup
  35384. if (isset($this->classMap[$class])) {
  35385. return $this->classMap[$class];
  35386. }
  35387. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  35388. return false;
  35389. }
  35390. if (null !== $this->apcuPrefix) {
  35391. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  35392. if ($hit) {
  35393. return $file;
  35394. }
  35395. }
  35396. $file = $this->findFileWithExtension($class, '.php');
  35397. // Search for Hack files if we are running on HHVM
  35398. if (false === $file && defined('HHVM_VERSION')) {
  35399. $file = $this->findFileWithExtension($class, '.hh');
  35400. }
  35401. if (null !== $this->apcuPrefix) {
  35402. apcu_add($this->apcuPrefix.$class, $file);
  35403. }
  35404. if (false === $file) {
  35405. // Remember that this class does not exist.
  35406. $this->missingClasses[$class] = true;
  35407. }
  35408. return $file;
  35409. }
  35410. /**
  35411. * Returns the currently registered loaders indexed by their corresponding vendor directories.
  35412. *
  35413. * @return self[]
  35414. */
  35415. public static function getRegisteredLoaders()
  35416. {
  35417. return self::$registeredLoaders;
  35418. }
  35419. /**
  35420. * @param string $class
  35421. * @param string $ext
  35422. * @return string|false
  35423. */
  35424. private function findFileWithExtension($class, $ext)
  35425. {
  35426. // PSR-4 lookup
  35427. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  35428. $first = $class[0];
  35429. if (isset($this->prefixLengthsPsr4[$first])) {
  35430. $subPath = $class;
  35431. while (false !== $lastPos = strrpos($subPath, '\\')) {
  35432. $subPath = substr($subPath, 0, $lastPos);
  35433. $search = $subPath . '\\';
  35434. if (isset($this->prefixDirsPsr4[$search])) {
  35435. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  35436. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  35437. if (file_exists($file = $dir . $pathEnd)) {
  35438. return $file;
  35439. }
  35440. }
  35441. }
  35442. }
  35443. }
  35444. // PSR-4 fallback dirs
  35445. foreach ($this->fallbackDirsPsr4 as $dir) {
  35446. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  35447. return $file;
  35448. }
  35449. }
  35450. // PSR-0 lookup
  35451. if (false !== $pos = strrpos($class, '\\')) {
  35452. // namespaced class name
  35453. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  35454. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  35455. } else {
  35456. // PEAR-like class name
  35457. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  35458. }
  35459. if (isset($this->prefixesPsr0[$first])) {
  35460. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  35461. if (0 === strpos($class, $prefix)) {
  35462. foreach ($dirs as $dir) {
  35463. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  35464. return $file;
  35465. }
  35466. }
  35467. }
  35468. }
  35469. }
  35470. // PSR-0 fallback dirs
  35471. foreach ($this->fallbackDirsPsr0 as $dir) {
  35472. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  35473. return $file;
  35474. }
  35475. }
  35476. // PSR-0 include paths.
  35477. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  35478. return $file;
  35479. }
  35480. return false;
  35481. }
  35482. }
  35483. /**
  35484. * Scope isolated include.
  35485. *
  35486. * Prevents access to $this/self from included files.
  35487. *
  35488. * @param string $file
  35489. * @return void
  35490. * @private
  35491. */
  35492. function includeFile($file)
  35493. {
  35494. include $file;
  35495. }
  35496. <?php
  35497. /*
  35498. * This file is part of Composer.
  35499. *
  35500. * (c) Nils Adermann <naderman@naderman.de>
  35501. * Jordi Boggiano <j.boggiano@seld.be>
  35502. *
  35503. * For the full copyright and license information, please view the LICENSE
  35504. * file that was distributed with this source code.
  35505. */
  35506. namespace Composer;
  35507. use Composer\Autoload\ClassLoader;
  35508. use Composer\Semver\VersionParser;
  35509. /**
  35510. * This class is copied in every Composer installed project and available to all
  35511. *
  35512. * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
  35513. *
  35514. * To require its presence, you can require `composer-runtime-api ^2.0`
  35515. */
  35516. class InstalledVersions
  35517. {
  35518. /**
  35519. * @var mixed[]|null
  35520. * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
  35521. */
  35522. private static $installed;
  35523. /**
  35524. * @var bool|null
  35525. */
  35526. private static $canGetVendors;
  35527. /**
  35528. * @var array[]
  35529. * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
  35530. */
  35531. private static $installedByVendor = array();
  35532. /**
  35533. * Returns a list of all package names which are present, either by being installed, replaced or provided
  35534. *
  35535. * @return string[]
  35536. * @psalm-return list<string>
  35537. */
  35538. public static function getInstalledPackages()
  35539. {
  35540. $packages = array();
  35541. foreach (self::getInstalled() as $installed) {
  35542. $packages[] = array_keys($installed['versions']);
  35543. }
  35544. if (1 === \count($packages)) {
  35545. return $packages[0];
  35546. }
  35547. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  35548. }
  35549. /**
  35550. * Returns a list of all package names with a specific type e.g. 'library'
  35551. *
  35552. * @param string $type
  35553. * @return string[]
  35554. * @psalm-return list<string>
  35555. */
  35556. public static function getInstalledPackagesByType($type)
  35557. {
  35558. $packagesByType = array();
  35559. foreach (self::getInstalled() as $installed) {
  35560. foreach ($installed['versions'] as $name => $package) {
  35561. if (isset($package['type']) && $package['type'] === $type) {
  35562. $packagesByType[] = $name;
  35563. }
  35564. }
  35565. }
  35566. return $packagesByType;
  35567. }
  35568. /**
  35569. * Checks whether the given package is installed
  35570. *
  35571. * This also returns true if the package name is provided or replaced by another package
  35572. *
  35573. * @param string $packageName
  35574. * @param bool $includeDevRequirements
  35575. * @return bool
  35576. */
  35577. public static function isInstalled($packageName, $includeDevRequirements = true)
  35578. {
  35579. foreach (self::getInstalled() as $installed) {
  35580. if (isset($installed['versions'][$packageName])) {
  35581. return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
  35582. }
  35583. }
  35584. return false;
  35585. }
  35586. /**
  35587. * Checks whether the given package satisfies a version constraint
  35588. *
  35589. * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
  35590. *
  35591. * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
  35592. *
  35593. * @param VersionParser $parser Install composer/semver to have access to this class and functionality
  35594. * @param string $packageName
  35595. * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
  35596. * @return bool
  35597. */
  35598. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  35599. {
  35600. $constraint = $parser->parseConstraints($constraint);
  35601. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  35602. return $provided->matches($constraint);
  35603. }
  35604. /**
  35605. * Returns a version constraint representing all the range(s) which are installed for a given package
  35606. *
  35607. * It is easier to use this via isInstalled() with the $constraint argument if you need to check
  35608. * whether a given version of a package is installed, and not just whether it exists
  35609. *
  35610. * @param string $packageName
  35611. * @return string Version constraint usable with composer/semver
  35612. */
  35613. public static function getVersionRanges($packageName)
  35614. {
  35615. foreach (self::getInstalled() as $installed) {
  35616. if (!isset($installed['versions'][$packageName])) {
  35617. continue;
  35618. }
  35619. $ranges = array();
  35620. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  35621. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  35622. }
  35623. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  35624. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  35625. }
  35626. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  35627. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  35628. }
  35629. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  35630. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  35631. }
  35632. return implode(' || ', $ranges);
  35633. }
  35634. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35635. }
  35636. /**
  35637. * @param string $packageName
  35638. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
  35639. */
  35640. public static function getVersion($packageName)
  35641. {
  35642. foreach (self::getInstalled() as $installed) {
  35643. if (!isset($installed['versions'][$packageName])) {
  35644. continue;
  35645. }
  35646. if (!isset($installed['versions'][$packageName]['version'])) {
  35647. return null;
  35648. }
  35649. return $installed['versions'][$packageName]['version'];
  35650. }
  35651. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35652. }
  35653. /**
  35654. * @param string $packageName
  35655. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
  35656. */
  35657. public static function getPrettyVersion($packageName)
  35658. {
  35659. foreach (self::getInstalled() as $installed) {
  35660. if (!isset($installed['versions'][$packageName])) {
  35661. continue;
  35662. }
  35663. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  35664. return null;
  35665. }
  35666. return $installed['versions'][$packageName]['pretty_version'];
  35667. }
  35668. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35669. }
  35670. /**
  35671. * @param string $packageName
  35672. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
  35673. */
  35674. public static function getReference($packageName)
  35675. {
  35676. foreach (self::getInstalled() as $installed) {
  35677. if (!isset($installed['versions'][$packageName])) {
  35678. continue;
  35679. }
  35680. if (!isset($installed['versions'][$packageName]['reference'])) {
  35681. return null;
  35682. }
  35683. return $installed['versions'][$packageName]['reference'];
  35684. }
  35685. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35686. }
  35687. /**
  35688. * @param string $packageName
  35689. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
  35690. */
  35691. public static function getInstallPath($packageName)
  35692. {
  35693. foreach (self::getInstalled() as $installed) {
  35694. if (!isset($installed['versions'][$packageName])) {
  35695. continue;
  35696. }
  35697. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  35698. }
  35699. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35700. }
  35701. /**
  35702. * @return array
  35703. * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
  35704. */
  35705. public static function getRootPackage()
  35706. {
  35707. $installed = self::getInstalled();
  35708. return $installed[0]['root'];
  35709. }
  35710. /**
  35711. * Returns the raw installed.php data for custom implementations
  35712. *
  35713. * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
  35714. * @return array[]
  35715. * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
  35716. */
  35717. public static function getRawData()
  35718. {
  35719. @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
  35720. if (null === self::$installed) {
  35721. // only require the installed.php file if this file is loaded from its dumped location,
  35722. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  35723. if (substr(__DIR__, -8, 1) !== 'C') {
  35724. self::$installed = include __DIR__ . '/installed.php';
  35725. } else {
  35726. self::$installed = array();
  35727. }
  35728. }
  35729. return self::$installed;
  35730. }
  35731. /**
  35732. * Returns the raw data of all installed.php which are currently loaded for custom implementations
  35733. *
  35734. * @return array[]
  35735. * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
  35736. */
  35737. public static function getAllRawData()
  35738. {
  35739. return self::getInstalled();
  35740. }
  35741. /**
  35742. * Lets you reload the static array from another file
  35743. *
  35744. * This is only useful for complex integrations in which a project needs to use
  35745. * this class but then also needs to execute another project's autoloader in process,
  35746. * and wants to ensure both projects have access to their version of installed.php.
  35747. *
  35748. * A typical case would be PHPUnit, where it would need to make sure it reads all
  35749. * the data it needs from this class, then call reload() with
  35750. * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
  35751. * the project in which it runs can then also use this class safely, without
  35752. * interference between PHPUnit's dependencies and the project's dependencies.
  35753. *
  35754. * @param array[] $data A vendor/composer/installed.php data set
  35755. * @return void
  35756. *
  35757. * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
  35758. */
  35759. public static function reload($data)
  35760. {
  35761. self::$installed = $data;
  35762. self::$installedByVendor = array();
  35763. }
  35764. /**
  35765. * @return array[]
  35766. * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
  35767. */
  35768. private static function getInstalled()
  35769. {
  35770. if (null === self::$canGetVendors) {
  35771. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  35772. }
  35773. $installed = array();
  35774. if (self::$canGetVendors) {
  35775. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  35776. if (isset(self::$installedByVendor[$vendorDir])) {
  35777. $installed[] = self::$installedByVendor[$vendorDir];
  35778. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  35779. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  35780. if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
  35781. self::$installed = $installed[count($installed) - 1];
  35782. }
  35783. }
  35784. }
  35785. }
  35786. if (null === self::$installed) {
  35787. // only require the installed.php file if this file is loaded from its dumped location,
  35788. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  35789. if (substr(__DIR__, -8, 1) !== 'C') {
  35790. self::$installed = require __DIR__ . '/installed.php';
  35791. } else {
  35792. self::$installed = array();
  35793. }
  35794. }
  35795. $installed[] = self::$installed;
  35796. return $installed;
  35797. }
  35798. }
  35799. {
  35800. "$schema": "https://json-schema.org/draft-04/schema#",
  35801. "description": "A representation of packages metadata.",
  35802. "type": "object",
  35803. "oneOf": [
  35804. { "required": [ "packages" ] },
  35805. { "required": [ "providers" ] },
  35806. { "required": [ "provider-includes", "providers-url" ] }
  35807. ],
  35808. "properties": {
  35809. "packages": {
  35810. "type": ["object", "array"],
  35811. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  35812. "additionalProperties": { "$ref": "#/definitions/versions" }
  35813. },
  35814. "providers-url": {
  35815. "type": "string",
  35816. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  35817. },
  35818. "provider-includes": {
  35819. "type": "object",
  35820. "description": "A hashmap of provider listings.",
  35821. "additionalProperties": { "$ref": "#/definitions/provider" }
  35822. },
  35823. "providers": {
  35824. "type": "object",
  35825. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  35826. "additionalProperties": { "$ref": "#/definitions/provider" }
  35827. },
  35828. "notify-batch": {
  35829. "type": "string",
  35830. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  35831. },
  35832. "search": {
  35833. "type": "string",
  35834. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  35835. },
  35836. "warning": {
  35837. "type": "string",
  35838. "description": "A message that will be output by Composer as a warning when this source is consulted."
  35839. }
  35840. },
  35841. "definitions": {
  35842. "versions": {
  35843. "type": "object",
  35844. "description": "A hashmap of versions and their metadata.",
  35845. "additionalProperties": { "$ref": "#/definitions/version" }
  35846. },
  35847. "version": {
  35848. "type": "object",
  35849. "oneOf": [
  35850. { "$ref": "#/definitions/package" },
  35851. { "$ref": "#/definitions/metapackage" }
  35852. ]
  35853. },
  35854. "package-base": {
  35855. "properties": {
  35856. "name": { "type": "string" },
  35857. "type": { "type": "string" },
  35858. "version": { "type": "string" },
  35859. "version_normalized": {
  35860. "type": "string",
  35861. "description": "Normalized version, optional but can save computational time on client side."
  35862. },
  35863. "autoload": { "type": "object" },
  35864. "require": { "type": "object" },
  35865. "replace": { "type": "object" },
  35866. "conflict": { "type": "object" },
  35867. "provide": { "type": "object" },
  35868. "time": { "type": "string" }
  35869. },
  35870. "additionalProperties": true
  35871. },
  35872. "package": {
  35873. "allOf": [
  35874. { "$ref": "#/definitions/package-base" },
  35875. {
  35876. "properties": {
  35877. "dist": { "type": "object" },
  35878. "source": { "type": "object" }
  35879. }
  35880. },
  35881. { "oneOf": [
  35882. { "required": [ "name", "version", "source" ] },
  35883. { "required": [ "name", "version", "dist" ] }
  35884. ] }
  35885. ]
  35886. },
  35887. "metapackage": {
  35888. "allOf": [
  35889. { "$ref": "#/definitions/package-base" },
  35890. {
  35891. "properties": {
  35892. "type": { "type": "string", "enum": [ "metapackage" ] }
  35893. },
  35894. "required": [ "name", "version", "type" ]
  35895. }
  35896. ]
  35897. },
  35898. "provider": {
  35899. "type": "object",
  35900. "properties": {
  35901. "sha256": {
  35902. "type": "string",
  35903. "description": "Hash value that can be used to validate the resource."
  35904. }
  35905. }
  35906. }
  35907. }
  35908. }
  35909. {
  35910. "$schema": "https://json-schema.org/draft-04/schema#",
  35911. "title": "Package",
  35912. "type": "object",
  35913. "properties": {
  35914. "name": {
  35915. "type": "string",
  35916. "description": "Package name, including 'vendor-name/' prefix.",
  35917. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$"
  35918. },
  35919. "type": {
  35920. "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.",
  35921. "type": "string",
  35922. "pattern": "^[a-z0-9-]+$"
  35923. },
  35924. "target-dir": {
  35925. "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.",
  35926. "type": "string"
  35927. },
  35928. "description": {
  35929. "type": "string",
  35930. "description": "Short package description."
  35931. },
  35932. "keywords": {
  35933. "type": "array",
  35934. "items": {
  35935. "type": "string",
  35936. "description": "A tag/keyword that this package relates to."
  35937. }
  35938. },
  35939. "homepage": {
  35940. "type": "string",
  35941. "description": "Homepage URL for the project.",
  35942. "format": "uri"
  35943. },
  35944. "readme": {
  35945. "type": "string",
  35946. "description": "Relative path to the readme document."
  35947. },
  35948. "version": {
  35949. "type": "string",
  35950. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  35951. "pattern": "^v?\\d+(\\.\\d+){0,3}|^dev-"
  35952. },
  35953. "time": {
  35954. "type": "string",
  35955. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  35956. },
  35957. "license": {
  35958. "type": ["string", "array"],
  35959. "description": "License name. Or an array of license names."
  35960. },
  35961. "authors": {
  35962. "$ref": "#/definitions/authors"
  35963. },
  35964. "require": {
  35965. "type": "object",
  35966. "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
  35967. "additionalProperties": {
  35968. "type": "string"
  35969. }
  35970. },
  35971. "replace": {
  35972. "type": "object",
  35973. "description": "This is a hash of package name (keys) and version constraints (values) that can be replaced by this package.",
  35974. "additionalProperties": {
  35975. "type": "string"
  35976. }
  35977. },
  35978. "conflict": {
  35979. "type": "object",
  35980. "description": "This is a hash of package name (keys) and version constraints (values) that conflict with this package.",
  35981. "additionalProperties": {
  35982. "type": "string"
  35983. }
  35984. },
  35985. "provide": {
  35986. "type": "object",
  35987. "description": "This is a hash of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  35988. "additionalProperties": {
  35989. "type": "string"
  35990. }
  35991. },
  35992. "require-dev": {
  35993. "type": "object",
  35994. "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  35995. "additionalProperties": {
  35996. "type": "string"
  35997. }
  35998. },
  35999. "suggest": {
  36000. "type": "object",
  36001. "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).",
  36002. "additionalProperties": {
  36003. "type": "string"
  36004. }
  36005. },
  36006. "config": {
  36007. "type": "object",
  36008. "description": "Composer options.",
  36009. "properties": {
  36010. "process-timeout": {
  36011. "type": "integer",
  36012. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  36013. },
  36014. "use-include-path": {
  36015. "type": "boolean",
  36016. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  36017. },
  36018. "preferred-install": {
  36019. "type": ["string", "object"],
  36020. "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\"}."
  36021. },
  36022. "notify-on-install": {
  36023. "type": "boolean",
  36024. "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."
  36025. },
  36026. "github-protocols": {
  36027. "type": "array",
  36028. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
  36029. "items": {
  36030. "type": "string"
  36031. }
  36032. },
  36033. "github-oauth": {
  36034. "type": "object",
  36035. "description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  36036. "additionalProperties": {
  36037. "type": "string"
  36038. }
  36039. },
  36040. "gitlab-oauth": {
  36041. "type": "object",
  36042. "description": "A hash of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
  36043. "additionalProperties": {
  36044. "type": "string"
  36045. }
  36046. },
  36047. "gitlab-token": {
  36048. "type": "object",
  36049. "description": "A hash of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
  36050. "additionalProperties": {
  36051. "type": "string"
  36052. }
  36053. },
  36054. "gitlab-protocol": {
  36055. "enum": ["git", "http", "https"],
  36056. "description": "A protocol to force use of when creating a repository URL for the `source` value of the package metadata. One of `git` or `http`. By default, Composer will generate a git URL for private repositories and http one for public repos."
  36057. },
  36058. "bearer": {
  36059. "type": "object",
  36060. "description": "A hash of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  36061. "additionalProperties": {
  36062. "type": "string"
  36063. }
  36064. },
  36065. "disable-tls": {
  36066. "type": "boolean",
  36067. "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."
  36068. },
  36069. "secure-http": {
  36070. "type": "boolean",
  36071. "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."
  36072. },
  36073. "secure-svn-domains": {
  36074. "type": "array",
  36075. "description": "A list of domains which should be trusted/marked as using a secure Subversion/SVN transport. By default svn:// protocol is seen as insecure and will throw. This is a better/safer alternative to disabling `secure-http` altogether.",
  36076. "items": {
  36077. "type": "string"
  36078. }
  36079. },
  36080. "cafile": {
  36081. "type": "string",
  36082. "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."
  36083. },
  36084. "capath": {
  36085. "type": "string",
  36086. "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."
  36087. },
  36088. "http-basic": {
  36089. "type": "object",
  36090. "description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  36091. "additionalProperties": {
  36092. "type": "object",
  36093. "required": ["username", "password"],
  36094. "properties": {
  36095. "username": {
  36096. "type": "string",
  36097. "description": "The username used for HTTP Basic authentication"
  36098. },
  36099. "password": {
  36100. "type": "string",
  36101. "description": "The password used for HTTP Basic authentication"
  36102. }
  36103. }
  36104. }
  36105. },
  36106. "store-auths": {
  36107. "type": ["string", "boolean"],
  36108. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  36109. },
  36110. "platform": {
  36111. "type": "object",
  36112. "description": "This is a hash of package name (keys) and version (values) that will be used to mock the platform packages on this machine.",
  36113. "additionalProperties": {
  36114. "type": "string"
  36115. }
  36116. },
  36117. "vendor-dir": {
  36118. "type": "string",
  36119. "description": "The location where all packages are installed, defaults to \"vendor\"."
  36120. },
  36121. "bin-dir": {
  36122. "type": "string",
  36123. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  36124. },
  36125. "data-dir": {
  36126. "type": "string",
  36127. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  36128. },
  36129. "cache-dir": {
  36130. "type": "string",
  36131. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  36132. },
  36133. "cache-files-dir": {
  36134. "type": "string",
  36135. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  36136. },
  36137. "cache-repo-dir": {
  36138. "type": "string",
  36139. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  36140. },
  36141. "cache-vcs-dir": {
  36142. "type": "string",
  36143. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  36144. },
  36145. "cache-ttl": {
  36146. "type": "integer",
  36147. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  36148. },
  36149. "cache-files-ttl": {
  36150. "type": "integer",
  36151. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  36152. },
  36153. "cache-files-maxsize": {
  36154. "type": ["string", "integer"],
  36155. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  36156. },
  36157. "cache-read-only": {
  36158. "type": ["boolean"],
  36159. "description": "Whether to use the Composer cache in read-only mode."
  36160. },
  36161. "bin-compat": {
  36162. "enum": ["auto", "full", "symlink"],
  36163. "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed), can be \"full\" (compatible with both Windows and Unix-based systems) and \"symlink\" (symlink also for WSL)."
  36164. },
  36165. "discard-changes": {
  36166. "type": ["string", "boolean"],
  36167. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  36168. },
  36169. "autoloader-suffix": {
  36170. "type": "string",
  36171. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  36172. },
  36173. "optimize-autoloader": {
  36174. "type": "boolean",
  36175. "description": "Always optimize when dumping the autoloader."
  36176. },
  36177. "prepend-autoloader": {
  36178. "type": "boolean",
  36179. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  36180. },
  36181. "classmap-authoritative": {
  36182. "type": "boolean",
  36183. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  36184. },
  36185. "apcu-autoloader": {
  36186. "type": "boolean",
  36187. "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."
  36188. },
  36189. "github-domains": {
  36190. "type": "array",
  36191. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  36192. "items": {
  36193. "type": "string"
  36194. }
  36195. },
  36196. "github-expose-hostname": {
  36197. "type": "boolean",
  36198. "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."
  36199. },
  36200. "gitlab-domains": {
  36201. "type": "array",
  36202. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  36203. "items": {
  36204. "type": "string"
  36205. }
  36206. },
  36207. "use-github-api": {
  36208. "type": "boolean",
  36209. "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."
  36210. },
  36211. "archive-format": {
  36212. "type": "string",
  36213. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  36214. },
  36215. "archive-dir": {
  36216. "type": "string",
  36217. "description": "The default archive path when not provided on cli, defaults to \".\"."
  36218. },
  36219. "htaccess-protect": {
  36220. "type": "boolean",
  36221. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  36222. },
  36223. "sort-packages": {
  36224. "type": "boolean",
  36225. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  36226. },
  36227. "lock": {
  36228. "type": "boolean",
  36229. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  36230. },
  36231. "platform-check": {
  36232. "type": ["boolean", "string"],
  36233. "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."
  36234. }
  36235. }
  36236. },
  36237. "extra": {
  36238. "type": ["object", "array"],
  36239. "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.",
  36240. "additionalProperties": true
  36241. },
  36242. "autoload": {
  36243. "$ref": "#/definitions/autoload"
  36244. },
  36245. "autoload-dev": {
  36246. "type": "object",
  36247. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  36248. "properties": {
  36249. "psr-0": {
  36250. "type": "object",
  36251. "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.",
  36252. "additionalProperties": {
  36253. "type": ["string", "array"],
  36254. "items": {
  36255. "type": "string"
  36256. }
  36257. }
  36258. },
  36259. "psr-4": {
  36260. "type": "object",
  36261. "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.",
  36262. "additionalProperties": {
  36263. "type": ["string", "array"],
  36264. "items": {
  36265. "type": "string"
  36266. }
  36267. }
  36268. },
  36269. "classmap": {
  36270. "type": "array",
  36271. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  36272. },
  36273. "files": {
  36274. "type": "array",
  36275. "description": "This is an array of files that are always required on every request."
  36276. }
  36277. }
  36278. },
  36279. "archive": {
  36280. "type": ["object"],
  36281. "description": "Options for creating package archives for distribution.",
  36282. "properties": {
  36283. "name": {
  36284. "type": "string",
  36285. "description": "A base name for archive."
  36286. },
  36287. "exclude": {
  36288. "type": "array",
  36289. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  36290. }
  36291. }
  36292. },
  36293. "repositories": {
  36294. "type": ["object", "array"],
  36295. "description": "A set of additional repositories where packages can be found.",
  36296. "additionalProperties": {
  36297. "anyOf": [
  36298. { "$ref": "#/definitions/repository" },
  36299. { "type": "boolean", "enum": [false] }
  36300. ]
  36301. },
  36302. "items": {
  36303. "anyOf": [
  36304. { "$ref": "#/definitions/repository" },
  36305. {
  36306. "type": "object",
  36307. "additionalProperties": { "type": "boolean", "enum": [false] },
  36308. "minProperties": 1,
  36309. "maxProperties": 1
  36310. }
  36311. ]
  36312. }
  36313. },
  36314. "minimum-stability": {
  36315. "type": ["string"],
  36316. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  36317. "enum": ["dev", "alpha", "beta", "rc", "RC", "stable"]
  36318. },
  36319. "prefer-stable": {
  36320. "type": ["boolean"],
  36321. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  36322. },
  36323. "bin": {
  36324. "type": ["string", "array"],
  36325. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  36326. "items": {
  36327. "type": "string"
  36328. }
  36329. },
  36330. "include-path": {
  36331. "type": ["array"],
  36332. "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.",
  36333. "items": {
  36334. "type": "string"
  36335. }
  36336. },
  36337. "scripts": {
  36338. "type": ["object"],
  36339. "description": "Script listeners that will be executed before/after some events.",
  36340. "properties": {
  36341. "pre-install-cmd": {
  36342. "type": ["array", "string"],
  36343. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  36344. },
  36345. "post-install-cmd": {
  36346. "type": ["array", "string"],
  36347. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  36348. },
  36349. "pre-update-cmd": {
  36350. "type": ["array", "string"],
  36351. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  36352. },
  36353. "post-update-cmd": {
  36354. "type": ["array", "string"],
  36355. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  36356. },
  36357. "pre-status-cmd": {
  36358. "type": ["array", "string"],
  36359. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  36360. },
  36361. "post-status-cmd": {
  36362. "type": ["array", "string"],
  36363. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  36364. },
  36365. "pre-package-install": {
  36366. "type": ["array", "string"],
  36367. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  36368. },
  36369. "post-package-install": {
  36370. "type": ["array", "string"],
  36371. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  36372. },
  36373. "pre-package-update": {
  36374. "type": ["array", "string"],
  36375. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  36376. },
  36377. "post-package-update": {
  36378. "type": ["array", "string"],
  36379. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  36380. },
  36381. "pre-package-uninstall": {
  36382. "type": ["array", "string"],
  36383. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  36384. },
  36385. "post-package-uninstall": {
  36386. "type": ["array", "string"],
  36387. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  36388. },
  36389. "pre-autoload-dump": {
  36390. "type": ["array", "string"],
  36391. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  36392. },
  36393. "post-autoload-dump": {
  36394. "type": ["array", "string"],
  36395. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  36396. },
  36397. "post-root-package-install": {
  36398. "type": ["array", "string"],
  36399. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  36400. },
  36401. "post-create-project-cmd": {
  36402. "type": ["array", "string"],
  36403. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  36404. }
  36405. }
  36406. },
  36407. "scripts-descriptions": {
  36408. "type": ["object"],
  36409. "description": "Descriptions for custom commands, shown in console help.",
  36410. "additionalProperties": {
  36411. "type": "string"
  36412. }
  36413. },
  36414. "support": {
  36415. "type": "object",
  36416. "properties": {
  36417. "email": {
  36418. "type": "string",
  36419. "description": "Email address for support.",
  36420. "format": "email"
  36421. },
  36422. "issues": {
  36423. "type": "string",
  36424. "description": "URL to the issue tracker.",
  36425. "format": "uri"
  36426. },
  36427. "forum": {
  36428. "type": "string",
  36429. "description": "URL to the forum.",
  36430. "format": "uri"
  36431. },
  36432. "wiki": {
  36433. "type": "string",
  36434. "description": "URL to the wiki.",
  36435. "format": "uri"
  36436. },
  36437. "irc": {
  36438. "type": "string",
  36439. "description": "IRC channel for support, as irc://server/channel.",
  36440. "format": "uri"
  36441. },
  36442. "chat": {
  36443. "type": "string",
  36444. "description": "URL to the support chat.",
  36445. "format": "uri"
  36446. },
  36447. "source": {
  36448. "type": "string",
  36449. "description": "URL to browse or download the sources.",
  36450. "format": "uri"
  36451. },
  36452. "docs": {
  36453. "type": "string",
  36454. "description": "URL to the documentation.",
  36455. "format": "uri"
  36456. },
  36457. "rss": {
  36458. "type": "string",
  36459. "description": "URL to the RSS feed.",
  36460. "format": "uri"
  36461. }
  36462. }
  36463. },
  36464. "funding": {
  36465. "type": "array",
  36466. "description": "A list of options to fund the development and maintenance of the package.",
  36467. "items": {
  36468. "type": "object",
  36469. "properties": {
  36470. "type": {
  36471. "type": "string",
  36472. "description": "Type of funding or platform through which funding is possible."
  36473. },
  36474. "url": {
  36475. "type": "string",
  36476. "description": "URL to a website with details on funding and a way to fund the package.",
  36477. "format": "uri"
  36478. }
  36479. }
  36480. }
  36481. },
  36482. "non-feature-branches": {
  36483. "type": ["array"],
  36484. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  36485. "items": {
  36486. "type": "string"
  36487. }
  36488. },
  36489. "default-branch": {
  36490. "type": ["boolean"],
  36491. "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."
  36492. },
  36493. "abandoned": {
  36494. "type": ["boolean", "string"],
  36495. "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."
  36496. },
  36497. "_comment": {
  36498. "type": ["array", "string"],
  36499. "description": "A key to store comments in"
  36500. }
  36501. },
  36502. "definitions": {
  36503. "authors": {
  36504. "type": "array",
  36505. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  36506. "items": {
  36507. "type": "object",
  36508. "additionalProperties": false,
  36509. "required": [ "name"],
  36510. "properties": {
  36511. "name": {
  36512. "type": "string",
  36513. "description": "Full name of the author."
  36514. },
  36515. "email": {
  36516. "type": "string",
  36517. "description": "Email address of the author.",
  36518. "format": "email"
  36519. },
  36520. "homepage": {
  36521. "type": "string",
  36522. "description": "Homepage URL for the author.",
  36523. "format": "uri"
  36524. },
  36525. "role": {
  36526. "type": "string",
  36527. "description": "Author's role in the project."
  36528. }
  36529. }
  36530. }
  36531. },
  36532. "autoload": {
  36533. "type": "object",
  36534. "description": "Description of how the package can be autoloaded.",
  36535. "properties": {
  36536. "psr-0": {
  36537. "type": "object",
  36538. "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.",
  36539. "additionalProperties": {
  36540. "type": ["string", "array"],
  36541. "items": {
  36542. "type": "string"
  36543. }
  36544. }
  36545. },
  36546. "psr-4": {
  36547. "type": "object",
  36548. "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.",
  36549. "additionalProperties": {
  36550. "type": ["string", "array"],
  36551. "items": {
  36552. "type": "string"
  36553. }
  36554. }
  36555. },
  36556. "classmap": {
  36557. "type": "array",
  36558. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  36559. },
  36560. "files": {
  36561. "type": "array",
  36562. "description": "This is an array of files that are always required on every request."
  36563. },
  36564. "exclude-from-classmap": {
  36565. "type": "array",
  36566. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  36567. }
  36568. }
  36569. },
  36570. "repository": {
  36571. "type": "object",
  36572. "anyOf": [
  36573. { "$ref": "#/definitions/composer-repository" },
  36574. { "$ref": "#/definitions/vcs-repository" },
  36575. { "$ref": "#/definitions/path-repository" },
  36576. { "$ref": "#/definitions/artifact-repository" },
  36577. { "$ref": "#/definitions/pear-repository" },
  36578. { "$ref": "#/definitions/package-repository" }
  36579. ]
  36580. },
  36581. "composer-repository": {
  36582. "type": "object",
  36583. "required": ["type", "url"],
  36584. "properties": {
  36585. "type": { "type": "string", "enum": ["composer"] },
  36586. "url": { "type": "string" },
  36587. "canonical": { "type": "boolean" },
  36588. "only": {
  36589. "type": "array",
  36590. "items": {
  36591. "type": "string"
  36592. }
  36593. },
  36594. "exclude": {
  36595. "type": "array",
  36596. "items": {
  36597. "type": "string"
  36598. }
  36599. },
  36600. "options": {
  36601. "type": "object",
  36602. "additionalProperties": true
  36603. },
  36604. "allow_ssl_downgrade": { "type": "boolean" },
  36605. "force-lazy-providers": { "type": "boolean" }
  36606. }
  36607. },
  36608. "vcs-repository": {
  36609. "type": "object",
  36610. "required": ["type", "url"],
  36611. "properties": {
  36612. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "git-bitbucket", "hg", "hg-bitbucket", "fossil", "perforce", "svn"] },
  36613. "url": { "type": "string" },
  36614. "canonical": { "type": "boolean" },
  36615. "only": {
  36616. "type": "array",
  36617. "items": {
  36618. "type": "string"
  36619. }
  36620. },
  36621. "exclude": {
  36622. "type": "array",
  36623. "items": {
  36624. "type": "string"
  36625. }
  36626. },
  36627. "no-api": { "type": "boolean" },
  36628. "secure-http": { "type": "boolean" },
  36629. "svn-cache-credentials": { "type": "boolean" },
  36630. "trunk-path": { "type": ["string", "boolean"] },
  36631. "branches-path": { "type": ["string", "boolean"] },
  36632. "tags-path": { "type": ["string", "boolean"] },
  36633. "package-path": { "type": "string" },
  36634. "depot": { "type": "string" },
  36635. "branch": { "type": "string" },
  36636. "unique_perforce_client_name": { "type": "string" },
  36637. "p4user": { "type": "string" },
  36638. "p4password": { "type": "string" }
  36639. }
  36640. },
  36641. "path-repository": {
  36642. "type": "object",
  36643. "required": ["type", "url"],
  36644. "properties": {
  36645. "type": { "type": "string", "enum": ["path"] },
  36646. "url": { "type": "string" },
  36647. "canonical": { "type": "boolean" },
  36648. "only": {
  36649. "type": "array",
  36650. "items": {
  36651. "type": "string"
  36652. }
  36653. },
  36654. "exclude": {
  36655. "type": "array",
  36656. "items": {
  36657. "type": "string"
  36658. }
  36659. },
  36660. "options": {
  36661. "type": "object",
  36662. "properties": {
  36663. "symlink": { "type": ["boolean", "null"] }
  36664. },
  36665. "additionalProperties": true
  36666. }
  36667. }
  36668. },
  36669. "artifact-repository": {
  36670. "type": "object",
  36671. "required": ["type", "url"],
  36672. "properties": {
  36673. "type": { "type": "string", "enum": ["artifact"] },
  36674. "url": { "type": "string" },
  36675. "canonical": { "type": "boolean" },
  36676. "only": {
  36677. "type": "array",
  36678. "items": {
  36679. "type": "string"
  36680. }
  36681. },
  36682. "exclude": {
  36683. "type": "array",
  36684. "items": {
  36685. "type": "string"
  36686. }
  36687. }
  36688. }
  36689. },
  36690. "pear-repository": {
  36691. "type": "object",
  36692. "required": ["type", "url"],
  36693. "properties": {
  36694. "type": { "type": "string", "enum": ["pear"] },
  36695. "url": { "type": "string" },
  36696. "canonical": { "type": "boolean" },
  36697. "only": {
  36698. "type": "array",
  36699. "items": {
  36700. "type": "string"
  36701. }
  36702. },
  36703. "exclude": {
  36704. "type": "array",
  36705. "items": {
  36706. "type": "string"
  36707. }
  36708. },
  36709. "vendor-alias": { "type": "string" }
  36710. }
  36711. },
  36712. "package-repository": {
  36713. "type": "object",
  36714. "required": ["type", "package"],
  36715. "properties": {
  36716. "type": { "type": "string", "enum": ["package"] },
  36717. "canonical": { "type": "boolean" },
  36718. "only": {
  36719. "type": "array",
  36720. "items": {
  36721. "type": "string"
  36722. }
  36723. },
  36724. "exclude": {
  36725. "type": "array",
  36726. "items": {
  36727. "type": "string"
  36728. }
  36729. },
  36730. "package": {
  36731. "oneOf": [
  36732. { "$ref": "#/definitions/inline-package" },
  36733. {
  36734. "type": "array",
  36735. "items": { "$ref": "#/definitions/inline-package" }
  36736. }
  36737. ]
  36738. }
  36739. }
  36740. },
  36741. "inline-package": {
  36742. "type": "object",
  36743. "required": ["name", "version"],
  36744. "properties": {
  36745. "name": {
  36746. "type": "string",
  36747. "description": "Package name, including 'vendor-name/' prefix."
  36748. },
  36749. "type": {
  36750. "type": "string"
  36751. },
  36752. "target-dir": {
  36753. "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.",
  36754. "type": "string"
  36755. },
  36756. "description": {
  36757. "type": "string"
  36758. },
  36759. "keywords": {
  36760. "type": "array",
  36761. "items": {
  36762. "type": "string"
  36763. }
  36764. },
  36765. "homepage": {
  36766. "type": "string",
  36767. "format": "uri"
  36768. },
  36769. "version": {
  36770. "type": "string"
  36771. },
  36772. "time": {
  36773. "type": "string"
  36774. },
  36775. "license": {
  36776. "type": [
  36777. "string",
  36778. "array"
  36779. ]
  36780. },
  36781. "authors": {
  36782. "$ref": "#/definitions/authors"
  36783. },
  36784. "require": {
  36785. "type": "object",
  36786. "additionalProperties": {
  36787. "type": "string"
  36788. }
  36789. },
  36790. "replace": {
  36791. "type": "object",
  36792. "additionalProperties": {
  36793. "type": "string"
  36794. }
  36795. },
  36796. "conflict": {
  36797. "type": "object",
  36798. "additionalProperties": {
  36799. "type": "string"
  36800. }
  36801. },
  36802. "provide": {
  36803. "type": "object",
  36804. "additionalProperties": {
  36805. "type": "string"
  36806. }
  36807. },
  36808. "require-dev": {
  36809. "type": "object",
  36810. "additionalProperties": {
  36811. "type": "string"
  36812. }
  36813. },
  36814. "suggest": {
  36815. "type": "object",
  36816. "additionalProperties": {
  36817. "type": "string"
  36818. }
  36819. },
  36820. "extra": {
  36821. "type": ["object", "array"],
  36822. "additionalProperties": true
  36823. },
  36824. "autoload": {
  36825. "$ref": "#/definitions/autoload"
  36826. },
  36827. "archive": {
  36828. "type": ["object"],
  36829. "properties": {
  36830. "exclude": {
  36831. "type": "array"
  36832. }
  36833. }
  36834. },
  36835. "bin": {
  36836. "type": ["string", "array"],
  36837. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  36838. "items": {
  36839. "type": "string"
  36840. }
  36841. },
  36842. "include-path": {
  36843. "type": ["array"],
  36844. "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.",
  36845. "items": {
  36846. "type": "string"
  36847. }
  36848. },
  36849. "source": {
  36850. "type": "object",
  36851. "required": ["type", "url", "reference"],
  36852. "properties": {
  36853. "type": {
  36854. "type": "string"
  36855. },
  36856. "url": {
  36857. "type": "string"
  36858. },
  36859. "reference": {
  36860. "type": "string"
  36861. },
  36862. "mirrors": {
  36863. "type": "array"
  36864. }
  36865. }
  36866. },
  36867. "dist": {
  36868. "type": "object",
  36869. "required": ["type", "url"],
  36870. "properties": {
  36871. "type": {
  36872. "type": "string"
  36873. },
  36874. "url": {
  36875. "type": "string"
  36876. },
  36877. "reference": {
  36878. "type": "string"
  36879. },
  36880. "shasum": {
  36881. "type": "string"
  36882. },
  36883. "mirrors": {
  36884. "type": "array"
  36885. }
  36886. }
  36887. }
  36888. },
  36889. "additionalProperties": true
  36890. }
  36891. }
  36892. }
  36893. <?php
  36894. require_once __DIR__ . '/composer/autoload_real.php';
  36895. return ComposerAutoloaderInitComposerPhar1638265903::getLoader();
  36896. <?php
  36897. namespace Composer\Autoload;
  36898. class ClassLoader
  36899. {
  36900. private $vendorDir;
  36901. private $prefixLengthsPsr4 = array();
  36902. private $prefixDirsPsr4 = array();
  36903. private $fallbackDirsPsr4 = array();
  36904. private $prefixesPsr0 = array();
  36905. private $fallbackDirsPsr0 = array();
  36906. private $useIncludePath = false;
  36907. private $classMap = array();
  36908. private $classMapAuthoritative = false;
  36909. private $missingClasses = array();
  36910. private $apcuPrefix;
  36911. private static $registeredLoaders = array();
  36912. public function __construct($vendorDir = null)
  36913. {
  36914. $this->vendorDir = $vendorDir;
  36915. }
  36916. public function getPrefixes()
  36917. {
  36918. if (!empty($this->prefixesPsr0)) {
  36919. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  36920. }
  36921. return array();
  36922. }
  36923. public function getPrefixesPsr4()
  36924. {
  36925. return $this->prefixDirsPsr4;
  36926. }
  36927. public function getFallbackDirs()
  36928. {
  36929. return $this->fallbackDirsPsr0;
  36930. }
  36931. public function getFallbackDirsPsr4()
  36932. {
  36933. return $this->fallbackDirsPsr4;
  36934. }
  36935. public function getClassMap()
  36936. {
  36937. return $this->classMap;
  36938. }
  36939. public function addClassMap(array $classMap)
  36940. {
  36941. if ($this->classMap) {
  36942. $this->classMap = array_merge($this->classMap, $classMap);
  36943. } else {
  36944. $this->classMap = $classMap;
  36945. }
  36946. }
  36947. public function add($prefix, $paths, $prepend = false)
  36948. {
  36949. if (!$prefix) {
  36950. if ($prepend) {
  36951. $this->fallbackDirsPsr0 = array_merge(
  36952. (array) $paths,
  36953. $this->fallbackDirsPsr0
  36954. );
  36955. } else {
  36956. $this->fallbackDirsPsr0 = array_merge(
  36957. $this->fallbackDirsPsr0,
  36958. (array) $paths
  36959. );
  36960. }
  36961. return;
  36962. }
  36963. $first = $prefix[0];
  36964. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  36965. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  36966. return;
  36967. }
  36968. if ($prepend) {
  36969. $this->prefixesPsr0[$first][$prefix] = array_merge(
  36970. (array) $paths,
  36971. $this->prefixesPsr0[$first][$prefix]
  36972. );
  36973. } else {
  36974. $this->prefixesPsr0[$first][$prefix] = array_merge(
  36975. $this->prefixesPsr0[$first][$prefix],
  36976. (array) $paths
  36977. );
  36978. }
  36979. }
  36980. public function addPsr4($prefix, $paths, $prepend = false)
  36981. {
  36982. if (!$prefix) {
  36983. if ($prepend) {
  36984. $this->fallbackDirsPsr4 = array_merge(
  36985. (array) $paths,
  36986. $this->fallbackDirsPsr4
  36987. );
  36988. } else {
  36989. $this->fallbackDirsPsr4 = array_merge(
  36990. $this->fallbackDirsPsr4,
  36991. (array) $paths
  36992. );
  36993. }
  36994. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  36995. $length = strlen($prefix);
  36996. if ('\\' !== $prefix[$length - 1]) {
  36997. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  36998. }
  36999. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  37000. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  37001. } elseif ($prepend) {
  37002. $this->prefixDirsPsr4[$prefix] = array_merge(
  37003. (array) $paths,
  37004. $this->prefixDirsPsr4[$prefix]
  37005. );
  37006. } else {
  37007. $this->prefixDirsPsr4[$prefix] = array_merge(
  37008. $this->prefixDirsPsr4[$prefix],
  37009. (array) $paths
  37010. );
  37011. }
  37012. }
  37013. public function set($prefix, $paths)
  37014. {
  37015. if (!$prefix) {
  37016. $this->fallbackDirsPsr0 = (array) $paths;
  37017. } else {
  37018. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  37019. }
  37020. }
  37021. public function setPsr4($prefix, $paths)
  37022. {
  37023. if (!$prefix) {
  37024. $this->fallbackDirsPsr4 = (array) $paths;
  37025. } else {
  37026. $length = strlen($prefix);
  37027. if ('\\' !== $prefix[$length - 1]) {
  37028. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  37029. }
  37030. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  37031. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  37032. }
  37033. }
  37034. public function setUseIncludePath($useIncludePath)
  37035. {
  37036. $this->useIncludePath = $useIncludePath;
  37037. }
  37038. public function getUseIncludePath()
  37039. {
  37040. return $this->useIncludePath;
  37041. }
  37042. public function setClassMapAuthoritative($classMapAuthoritative)
  37043. {
  37044. $this->classMapAuthoritative = $classMapAuthoritative;
  37045. }
  37046. public function isClassMapAuthoritative()
  37047. {
  37048. return $this->classMapAuthoritative;
  37049. }
  37050. public function setApcuPrefix($apcuPrefix)
  37051. {
  37052. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  37053. }
  37054. public function getApcuPrefix()
  37055. {
  37056. return $this->apcuPrefix;
  37057. }
  37058. public function register($prepend = false)
  37059. {
  37060. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  37061. if (null === $this->vendorDir) {
  37062. return;
  37063. }
  37064. if ($prepend) {
  37065. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  37066. } else {
  37067. unset(self::$registeredLoaders[$this->vendorDir]);
  37068. self::$registeredLoaders[$this->vendorDir] = $this;
  37069. }
  37070. }
  37071. public function unregister()
  37072. {
  37073. spl_autoload_unregister(array($this, 'loadClass'));
  37074. if (null !== $this->vendorDir) {
  37075. unset(self::$registeredLoaders[$this->vendorDir]);
  37076. }
  37077. }
  37078. public function loadClass($class)
  37079. {
  37080. if ($file = $this->findFile($class)) {
  37081. includeFile($file);
  37082. return true;
  37083. }
  37084. return null;
  37085. }
  37086. public function findFile($class)
  37087. {
  37088. if (isset($this->classMap[$class])) {
  37089. return $this->classMap[$class];
  37090. }
  37091. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  37092. return false;
  37093. }
  37094. if (null !== $this->apcuPrefix) {
  37095. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  37096. if ($hit) {
  37097. return $file;
  37098. }
  37099. }
  37100. $file = $this->findFileWithExtension($class, '.php');
  37101. if (false === $file && defined('HHVM_VERSION')) {
  37102. $file = $this->findFileWithExtension($class, '.hh');
  37103. }
  37104. if (null !== $this->apcuPrefix) {
  37105. apcu_add($this->apcuPrefix.$class, $file);
  37106. }
  37107. if (false === $file) {
  37108. $this->missingClasses[$class] = true;
  37109. }
  37110. return $file;
  37111. }
  37112. public static function getRegisteredLoaders()
  37113. {
  37114. return self::$registeredLoaders;
  37115. }
  37116. private function findFileWithExtension($class, $ext)
  37117. {
  37118. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  37119. $first = $class[0];
  37120. if (isset($this->prefixLengthsPsr4[$first])) {
  37121. $subPath = $class;
  37122. while (false !== $lastPos = strrpos($subPath, '\\')) {
  37123. $subPath = substr($subPath, 0, $lastPos);
  37124. $search = $subPath . '\\';
  37125. if (isset($this->prefixDirsPsr4[$search])) {
  37126. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  37127. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  37128. if (file_exists($file = $dir . $pathEnd)) {
  37129. return $file;
  37130. }
  37131. }
  37132. }
  37133. }
  37134. }
  37135. foreach ($this->fallbackDirsPsr4 as $dir) {
  37136. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  37137. return $file;
  37138. }
  37139. }
  37140. if (false !== $pos = strrpos($class, '\\')) {
  37141. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  37142. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  37143. } else {
  37144. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  37145. }
  37146. if (isset($this->prefixesPsr0[$first])) {
  37147. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  37148. if (0 === strpos($class, $prefix)) {
  37149. foreach ($dirs as $dir) {
  37150. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  37151. return $file;
  37152. }
  37153. }
  37154. }
  37155. }
  37156. }
  37157. foreach ($this->fallbackDirsPsr0 as $dir) {
  37158. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  37159. return $file;
  37160. }
  37161. }
  37162. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  37163. return $file;
  37164. }
  37165. return false;
  37166. }
  37167. }
  37168. function includeFile($file)
  37169. {
  37170. include $file;
  37171. }
  37172. <?php
  37173. namespace Composer;
  37174. use Composer\Autoload\ClassLoader;
  37175. use Composer\Semver\VersionParser;
  37176. class InstalledVersions
  37177. {
  37178. private static $installed;
  37179. private static $canGetVendors;
  37180. private static $installedByVendor = array();
  37181. public static function getInstalledPackages()
  37182. {
  37183. $packages = array();
  37184. foreach (self::getInstalled() as $installed) {
  37185. $packages[] = array_keys($installed['versions']);
  37186. }
  37187. if (1 === \count($packages)) {
  37188. return $packages[0];
  37189. }
  37190. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  37191. }
  37192. public static function getInstalledPackagesByType($type)
  37193. {
  37194. $packagesByType = array();
  37195. foreach (self::getInstalled() as $installed) {
  37196. foreach ($installed['versions'] as $name => $package) {
  37197. if (isset($package['type']) && $package['type'] === $type) {
  37198. $packagesByType[] = $name;
  37199. }
  37200. }
  37201. }
  37202. return $packagesByType;
  37203. }
  37204. public static function isInstalled($packageName, $includeDevRequirements = true)
  37205. {
  37206. foreach (self::getInstalled() as $installed) {
  37207. if (isset($installed['versions'][$packageName])) {
  37208. return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
  37209. }
  37210. }
  37211. return false;
  37212. }
  37213. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  37214. {
  37215. $constraint = $parser->parseConstraints($constraint);
  37216. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  37217. return $provided->matches($constraint);
  37218. }
  37219. public static function getVersionRanges($packageName)
  37220. {
  37221. foreach (self::getInstalled() as $installed) {
  37222. if (!isset($installed['versions'][$packageName])) {
  37223. continue;
  37224. }
  37225. $ranges = array();
  37226. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  37227. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  37228. }
  37229. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  37230. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  37231. }
  37232. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  37233. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  37234. }
  37235. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  37236. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  37237. }
  37238. return implode(' || ', $ranges);
  37239. }
  37240. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37241. }
  37242. public static function getVersion($packageName)
  37243. {
  37244. foreach (self::getInstalled() as $installed) {
  37245. if (!isset($installed['versions'][$packageName])) {
  37246. continue;
  37247. }
  37248. if (!isset($installed['versions'][$packageName]['version'])) {
  37249. return null;
  37250. }
  37251. return $installed['versions'][$packageName]['version'];
  37252. }
  37253. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37254. }
  37255. public static function getPrettyVersion($packageName)
  37256. {
  37257. foreach (self::getInstalled() as $installed) {
  37258. if (!isset($installed['versions'][$packageName])) {
  37259. continue;
  37260. }
  37261. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  37262. return null;
  37263. }
  37264. return $installed['versions'][$packageName]['pretty_version'];
  37265. }
  37266. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37267. }
  37268. public static function getReference($packageName)
  37269. {
  37270. foreach (self::getInstalled() as $installed) {
  37271. if (!isset($installed['versions'][$packageName])) {
  37272. continue;
  37273. }
  37274. if (!isset($installed['versions'][$packageName]['reference'])) {
  37275. return null;
  37276. }
  37277. return $installed['versions'][$packageName]['reference'];
  37278. }
  37279. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37280. }
  37281. public static function getInstallPath($packageName)
  37282. {
  37283. foreach (self::getInstalled() as $installed) {
  37284. if (!isset($installed['versions'][$packageName])) {
  37285. continue;
  37286. }
  37287. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  37288. }
  37289. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37290. }
  37291. public static function getRootPackage()
  37292. {
  37293. $installed = self::getInstalled();
  37294. return $installed[0]['root'];
  37295. }
  37296. public static function getRawData()
  37297. {
  37298. @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
  37299. if (null === self::$installed) {
  37300. if (substr(__DIR__, -8, 1) !== 'C') {
  37301. self::$installed = include __DIR__ . '/installed.php';
  37302. } else {
  37303. self::$installed = array();
  37304. }
  37305. }
  37306. return self::$installed;
  37307. }
  37308. public static function getAllRawData()
  37309. {
  37310. return self::getInstalled();
  37311. }
  37312. public static function reload($data)
  37313. {
  37314. self::$installed = $data;
  37315. self::$installedByVendor = array();
  37316. }
  37317. private static function getInstalled()
  37318. {
  37319. if (null === self::$canGetVendors) {
  37320. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  37321. }
  37322. $installed = array();
  37323. if (self::$canGetVendors) {
  37324. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  37325. if (isset(self::$installedByVendor[$vendorDir])) {
  37326. $installed[] = self::$installedByVendor[$vendorDir];
  37327. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  37328. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  37329. if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
  37330. self::$installed = $installed[count($installed) - 1];
  37331. }
  37332. }
  37333. }
  37334. }
  37335. if (null === self::$installed) {
  37336. if (substr(__DIR__, -8, 1) !== 'C') {
  37337. self::$installed = require __DIR__ . '/installed.php';
  37338. } else {
  37339. self::$installed = array();
  37340. }
  37341. }
  37342. $installed[] = self::$installed;
  37343. return $installed;
  37344. }
  37345. }
  37346. <?php
  37347. $vendorDir = dirname(dirname(__FILE__));
  37348. $baseDir = dirname($vendorDir);
  37349. return array(
  37350. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  37351. );
  37352. <?php
  37353. $vendorDir = dirname(dirname(__FILE__));
  37354. $baseDir = dirname($vendorDir);
  37355. return array(
  37356. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  37357. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  37358. '7844cce90d4037f1a077c08319eef109' => $vendorDir . '/react/promise/src/React/Promise/functions_include.php',
  37359. );
  37360. <?php
  37361. $vendorDir = dirname(dirname(__FILE__));
  37362. $baseDir = dirname($vendorDir);
  37363. return array(
  37364. 'React\\Promise' => array($vendorDir . '/react/promise/src'),
  37365. );
  37366. <?php
  37367. $vendorDir = dirname(dirname(__FILE__));
  37368. $baseDir = dirname($vendorDir);
  37369. return array(
  37370. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  37371. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  37372. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  37373. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  37374. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  37375. 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
  37376. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  37377. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  37378. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  37379. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  37380. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  37381. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  37382. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  37383. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  37384. 'Composer\\MetadataMinifier\\' => array($vendorDir . '/composer/metadata-minifier/src'),
  37385. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  37386. 'Composer\\' => array($baseDir . '/src/Composer'),
  37387. );
  37388. <?php
  37389. class ComposerAutoloaderInitComposerPhar1638265903
  37390. {
  37391. private static $loader;
  37392. public static function loadClassLoader($class)
  37393. {
  37394. if ('Composer\Autoload\ClassLoader' === $class) {
  37395. require __DIR__ . '/ClassLoader.php';
  37396. }
  37397. }
  37398. public static function getLoader()
  37399. {
  37400. if (null !== self::$loader) {
  37401. return self::$loader;
  37402. }
  37403. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1638265903', 'loadClassLoader'), true, true);
  37404. self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
  37405. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1638265903', 'loadClassLoader'));
  37406. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  37407. if ($useStaticLoader) {
  37408. require __DIR__ . '/autoload_static.php';
  37409. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1638265903::getInitializer($loader));
  37410. } else {
  37411. $map = require __DIR__ . '/autoload_namespaces.php';
  37412. foreach ($map as $namespace => $path) {
  37413. $loader->set($namespace, $path);
  37414. }
  37415. $map = require __DIR__ . '/autoload_psr4.php';
  37416. foreach ($map as $namespace => $path) {
  37417. $loader->setPsr4($namespace, $path);
  37418. }
  37419. $classMap = require __DIR__ . '/autoload_classmap.php';
  37420. if ($classMap) {
  37421. $loader->addClassMap($classMap);
  37422. }
  37423. }
  37424. $loader->register(true);
  37425. if ($useStaticLoader) {
  37426. $includeFiles = Composer\Autoload\ComposerStaticInitComposerPhar1638265903::$files;
  37427. } else {
  37428. $includeFiles = require __DIR__ . '/autoload_files.php';
  37429. }
  37430. foreach ($includeFiles as $fileIdentifier => $file) {
  37431. composerRequireComposerPhar1638265903($fileIdentifier, $file);
  37432. }
  37433. return $loader;
  37434. }
  37435. }
  37436. function composerRequireComposerPhar1638265903($fileIdentifier, $file)
  37437. {
  37438. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  37439. require $file;
  37440. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  37441. }
  37442. }
  37443. <?php
  37444. namespace Composer\Autoload;
  37445. class ComposerStaticInitComposerPhar1638265903
  37446. {
  37447. public static $files = array (
  37448. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  37449. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  37450. '7844cce90d4037f1a077c08319eef109' => __DIR__ . '/..' . '/react/promise/src/React/Promise/functions_include.php',
  37451. );
  37452. public static $prefixLengthsPsr4 = array (
  37453. 'S' =>
  37454. array (
  37455. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  37456. 'Symfony\\Polyfill\\Ctype\\' => 23,
  37457. 'Symfony\\Component\\Process\\' => 26,
  37458. 'Symfony\\Component\\Finder\\' => 25,
  37459. 'Symfony\\Component\\Filesystem\\' => 29,
  37460. 'Symfony\\Component\\Debug\\' => 24,
  37461. 'Symfony\\Component\\Console\\' => 26,
  37462. 'Seld\\PharUtils\\' => 15,
  37463. 'Seld\\JsonLint\\' => 14,
  37464. ),
  37465. 'P' =>
  37466. array (
  37467. 'Psr\\Log\\' => 8,
  37468. ),
  37469. 'J' =>
  37470. array (
  37471. 'JsonSchema\\' => 11,
  37472. ),
  37473. 'C' =>
  37474. array (
  37475. 'Composer\\XdebugHandler\\' => 23,
  37476. 'Composer\\Spdx\\' => 14,
  37477. 'Composer\\Semver\\' => 16,
  37478. 'Composer\\MetadataMinifier\\' => 26,
  37479. 'Composer\\CaBundle\\' => 18,
  37480. 'Composer\\' => 9,
  37481. ),
  37482. );
  37483. public static $prefixDirsPsr4 = array (
  37484. 'Symfony\\Polyfill\\Mbstring\\' =>
  37485. array (
  37486. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  37487. ),
  37488. 'Symfony\\Polyfill\\Ctype\\' =>
  37489. array (
  37490. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  37491. ),
  37492. 'Symfony\\Component\\Process\\' =>
  37493. array (
  37494. 0 => __DIR__ . '/..' . '/symfony/process',
  37495. ),
  37496. 'Symfony\\Component\\Finder\\' =>
  37497. array (
  37498. 0 => __DIR__ . '/..' . '/symfony/finder',
  37499. ),
  37500. 'Symfony\\Component\\Filesystem\\' =>
  37501. array (
  37502. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  37503. ),
  37504. 'Symfony\\Component\\Debug\\' =>
  37505. array (
  37506. 0 => __DIR__ . '/..' . '/symfony/debug',
  37507. ),
  37508. 'Symfony\\Component\\Console\\' =>
  37509. array (
  37510. 0 => __DIR__ . '/..' . '/symfony/console',
  37511. ),
  37512. 'Seld\\PharUtils\\' =>
  37513. array (
  37514. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  37515. ),
  37516. 'Seld\\JsonLint\\' =>
  37517. array (
  37518. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  37519. ),
  37520. 'Psr\\Log\\' =>
  37521. array (
  37522. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  37523. ),
  37524. 'JsonSchema\\' =>
  37525. array (
  37526. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  37527. ),
  37528. 'Composer\\XdebugHandler\\' =>
  37529. array (
  37530. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  37531. ),
  37532. 'Composer\\Spdx\\' =>
  37533. array (
  37534. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  37535. ),
  37536. 'Composer\\Semver\\' =>
  37537. array (
  37538. 0 => __DIR__ . '/..' . '/composer/semver/src',
  37539. ),
  37540. 'Composer\\MetadataMinifier\\' =>
  37541. array (
  37542. 0 => __DIR__ . '/..' . '/composer/metadata-minifier/src',
  37543. ),
  37544. 'Composer\\CaBundle\\' =>
  37545. array (
  37546. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  37547. ),
  37548. 'Composer\\' =>
  37549. array (
  37550. 0 => __DIR__ . '/../..' . '/src/Composer',
  37551. ),
  37552. );
  37553. public static $prefixesPsr0 = array (
  37554. 'R' =>
  37555. array (
  37556. 'React\\Promise' =>
  37557. array (
  37558. 0 => __DIR__ . '/..' . '/react/promise/src',
  37559. ),
  37560. ),
  37561. );
  37562. public static $classMap = array (
  37563. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  37564. );
  37565. public static function getInitializer(ClassLoader $loader)
  37566. {
  37567. return \Closure::bind(function () use ($loader) {
  37568. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1638265903::$prefixLengthsPsr4;
  37569. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1638265903::$prefixDirsPsr4;
  37570. $loader->prefixesPsr0 = ComposerStaticInitComposerPhar1638265903::$prefixesPsr0;
  37571. $loader->classMap = ComposerStaticInitComposerPhar1638265903::$classMap;
  37572. }, null, ClassLoader::class);
  37573. }
  37574. }
  37575. Copyright (C) 2016 Composer
  37576. Permission is hereby granted, free of charge, to any person obtaining a copy of
  37577. this software and associated documentation files (the "Software"), to deal in
  37578. the Software without restriction, including without limitation the rights to
  37579. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  37580. of the Software, and to permit persons to whom the Software is furnished to do
  37581. so, subject to the following conditions:
  37582. The above copyright notice and this permission notice shall be included in all
  37583. copies or substantial portions of the Software.
  37584. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  37585. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  37586. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  37587. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  37588. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  37589. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  37590. SOFTWARE.
  37591. ##
  37592. ## Bundle of CA Root Certificates
  37593. ##
  37594. ## Certificate data from Mozilla as of: Tue Oct 26 03:12:05 2021 GMT
  37595. ##
  37596. ## This is a bundle of X.509 certificates of public Certificate Authorities
  37597. ## (CA). These were automatically extracted from Mozilla's root certificates
  37598. ## file (certdata.txt). This file can be found in the mozilla source tree:
  37599. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  37600. ##
  37601. ## It contains the certificates in PEM format and therefore
  37602. ## can be directly used with curl / libcurl / php_curl, or with
  37603. ## an Apache+mod_ssl webserver for SSL client authentication.
  37604. ## Just configure this file as the SSLCACertificateFile.
  37605. ##
  37606. ## Conversion done with mk-ca-bundle.pl version 1.28.
  37607. ## SHA256: bb36818a81feaa4cca61101e6d6276cd09e972efcb08112dfed846918ca41d7f
  37608. ##
  37609. GlobalSign Root CA
  37610. ==================
  37611. -----BEGIN CERTIFICATE-----
  37612. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  37613. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  37614. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  37615. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  37616. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  37617. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  37618. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  37619. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  37620. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  37621. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  37622. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  37623. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  37624. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  37625. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  37626. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  37627. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  37628. -----END CERTIFICATE-----
  37629. GlobalSign Root CA - R2
  37630. =======================
  37631. -----BEGIN CERTIFICATE-----
  37632. MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
  37633. YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  37634. bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  37635. aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  37636. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6
  37637. ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp
  37638. s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN
  37639. S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL
  37640. TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C
  37641. ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E
  37642. FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i
  37643. YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN
  37644. BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp
  37645. 9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu
  37646. 01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7
  37647. 9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7
  37648. TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
  37649. -----END CERTIFICATE-----
  37650. Entrust.net Premium 2048 Secure Server CA
  37651. =========================================
  37652. -----BEGIN CERTIFICATE-----
  37653. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  37654. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  37655. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  37656. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  37657. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  37658. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  37659. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  37660. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  37661. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  37662. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  37663. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  37664. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  37665. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  37666. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  37667. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  37668. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  37669. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  37670. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  37671. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  37672. -----END CERTIFICATE-----
  37673. Baltimore CyberTrust Root
  37674. =========================
  37675. -----BEGIN CERTIFICATE-----
  37676. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  37677. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  37678. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  37679. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  37680. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  37681. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  37682. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  37683. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  37684. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  37685. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  37686. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  37687. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  37688. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  37689. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  37690. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  37691. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  37692. -----END CERTIFICATE-----
  37693. Entrust Root Certification Authority
  37694. ====================================
  37695. -----BEGIN CERTIFICATE-----
  37696. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  37697. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  37698. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  37699. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  37700. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  37701. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  37702. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  37703. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  37704. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  37705. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  37706. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  37707. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  37708. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  37709. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  37710. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  37711. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  37712. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  37713. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  37714. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  37715. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  37716. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  37717. -----END CERTIFICATE-----
  37718. Comodo AAA Services root
  37719. ========================
  37720. -----BEGIN CERTIFICATE-----
  37721. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  37722. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  37723. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  37724. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  37725. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  37726. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  37727. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  37728. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  37729. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  37730. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  37731. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  37732. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  37733. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  37734. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  37735. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  37736. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  37737. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  37738. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  37739. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  37740. -----END CERTIFICATE-----
  37741. QuoVadis Root CA 2
  37742. ==================
  37743. -----BEGIN CERTIFICATE-----
  37744. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  37745. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  37746. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  37747. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  37748. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  37749. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  37750. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  37751. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  37752. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  37753. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  37754. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  37755. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  37756. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  37757. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  37758. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  37759. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  37760. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  37761. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  37762. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  37763. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  37764. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  37765. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  37766. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  37767. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  37768. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  37769. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  37770. -----END CERTIFICATE-----
  37771. QuoVadis Root CA 3
  37772. ==================
  37773. -----BEGIN CERTIFICATE-----
  37774. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  37775. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  37776. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  37777. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  37778. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  37779. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  37780. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  37781. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  37782. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  37783. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  37784. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  37785. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  37786. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  37787. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  37788. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  37789. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  37790. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  37791. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  37792. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  37793. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  37794. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  37795. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  37796. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  37797. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  37798. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  37799. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  37800. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  37801. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  37802. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  37803. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  37804. -----END CERTIFICATE-----
  37805. Security Communication Root CA
  37806. ==============================
  37807. -----BEGIN CERTIFICATE-----
  37808. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  37809. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  37810. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  37811. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  37812. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  37813. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  37814. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  37815. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  37816. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  37817. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  37818. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  37819. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  37820. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  37821. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  37822. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  37823. FL39vmwLAw==
  37824. -----END CERTIFICATE-----
  37825. XRamp Global CA Root
  37826. ====================
  37827. -----BEGIN CERTIFICATE-----
  37828. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  37829. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  37830. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  37831. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  37832. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  37833. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  37834. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  37835. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  37836. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  37837. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  37838. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  37839. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  37840. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  37841. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  37842. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  37843. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  37844. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  37845. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  37846. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  37847. -----END CERTIFICATE-----
  37848. Go Daddy Class 2 CA
  37849. ===================
  37850. -----BEGIN CERTIFICATE-----
  37851. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  37852. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  37853. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  37854. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  37855. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  37856. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  37857. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  37858. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  37859. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  37860. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  37861. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  37862. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  37863. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  37864. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  37865. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  37866. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  37867. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  37868. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  37869. vZ8=
  37870. -----END CERTIFICATE-----
  37871. Starfield Class 2 CA
  37872. ====================
  37873. -----BEGIN CERTIFICATE-----
  37874. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  37875. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  37876. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  37877. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  37878. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  37879. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  37880. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  37881. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  37882. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  37883. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  37884. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  37885. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  37886. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  37887. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  37888. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  37889. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  37890. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  37891. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  37892. QBFGmh95DmK/D5fs4C8fF5Q=
  37893. -----END CERTIFICATE-----
  37894. DigiCert Assured ID Root CA
  37895. ===========================
  37896. -----BEGIN CERTIFICATE-----
  37897. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  37898. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  37899. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  37900. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  37901. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  37902. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  37903. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  37904. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  37905. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  37906. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  37907. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  37908. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  37909. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  37910. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  37911. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  37912. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  37913. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  37914. -----END CERTIFICATE-----
  37915. DigiCert Global Root CA
  37916. =======================
  37917. -----BEGIN CERTIFICATE-----
  37918. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  37919. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  37920. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  37921. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  37922. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  37923. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  37924. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  37925. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  37926. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  37927. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  37928. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  37929. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  37930. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  37931. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  37932. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  37933. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  37934. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  37935. -----END CERTIFICATE-----
  37936. DigiCert High Assurance EV Root CA
  37937. ==================================
  37938. -----BEGIN CERTIFICATE-----
  37939. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  37940. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  37941. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  37942. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  37943. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  37944. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  37945. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  37946. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  37947. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  37948. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  37949. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  37950. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  37951. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  37952. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  37953. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  37954. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  37955. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  37956. -----END CERTIFICATE-----
  37957. SwissSign Gold CA - G2
  37958. ======================
  37959. -----BEGIN CERTIFICATE-----
  37960. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  37961. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  37962. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  37963. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  37964. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  37965. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  37966. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  37967. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  37968. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  37969. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  37970. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  37971. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  37972. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  37973. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  37974. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  37975. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  37976. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  37977. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  37978. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  37979. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  37980. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  37981. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  37982. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  37983. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  37984. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  37985. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  37986. -----END CERTIFICATE-----
  37987. SwissSign Silver CA - G2
  37988. ========================
  37989. -----BEGIN CERTIFICATE-----
  37990. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  37991. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  37992. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  37993. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  37994. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  37995. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  37996. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  37997. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  37998. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  37999. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  38000. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  38001. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  38002. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  38003. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  38004. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  38005. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  38006. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  38007. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  38008. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  38009. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  38010. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  38011. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  38012. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  38013. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  38014. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  38015. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  38016. -----END CERTIFICATE-----
  38017. SecureTrust CA
  38018. ==============
  38019. -----BEGIN CERTIFICATE-----
  38020. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  38021. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  38022. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  38023. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  38024. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  38025. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  38026. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  38027. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  38028. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  38029. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  38030. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  38031. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  38032. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  38033. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  38034. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  38035. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  38036. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  38037. -----END CERTIFICATE-----
  38038. Secure Global CA
  38039. ================
  38040. -----BEGIN CERTIFICATE-----
  38041. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  38042. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  38043. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  38044. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  38045. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  38046. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  38047. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  38048. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  38049. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  38050. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  38051. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  38052. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  38053. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  38054. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  38055. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  38056. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  38057. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  38058. -----END CERTIFICATE-----
  38059. COMODO Certification Authority
  38060. ==============================
  38061. -----BEGIN CERTIFICATE-----
  38062. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  38063. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  38064. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  38065. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  38066. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  38067. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  38068. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  38069. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  38070. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  38071. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  38072. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  38073. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  38074. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  38075. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  38076. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  38077. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  38078. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  38079. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  38080. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  38081. -----END CERTIFICATE-----
  38082. Network Solutions Certificate Authority
  38083. =======================================
  38084. -----BEGIN CERTIFICATE-----
  38085. MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG
  38086. EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr
  38087. IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx
  38088. MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu
  38089. MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G
  38090. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx
  38091. jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT
  38092. aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT
  38093. crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc
  38094. /Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB
  38095. AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP
  38096. BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv
  38097. bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA
  38098. A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q
  38099. 4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/
  38100. GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv
  38101. wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD
  38102. ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey
  38103. -----END CERTIFICATE-----
  38104. COMODO ECC Certification Authority
  38105. ==================================
  38106. -----BEGIN CERTIFICATE-----
  38107. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  38108. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  38109. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  38110. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  38111. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  38112. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  38113. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  38114. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  38115. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  38116. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  38117. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  38118. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  38119. -----END CERTIFICATE-----
  38120. Certigna
  38121. ========
  38122. -----BEGIN CERTIFICATE-----
  38123. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  38124. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  38125. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  38126. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  38127. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  38128. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  38129. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  38130. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  38131. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  38132. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  38133. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  38134. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  38135. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  38136. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  38137. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  38138. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  38139. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  38140. -----END CERTIFICATE-----
  38141. Cybertrust Global Root
  38142. ======================
  38143. -----BEGIN CERTIFICATE-----
  38144. MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li
  38145. ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4
  38146. MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD
  38147. ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
  38148. +Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW
  38149. 0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL
  38150. AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin
  38151. 89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT
  38152. 8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP
  38153. BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2
  38154. MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G
  38155. A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO
  38156. lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi
  38157. 5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2
  38158. hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T
  38159. X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW
  38160. WL1WMRJOEcgh4LMRkWXbtKaIOM5V
  38161. -----END CERTIFICATE-----
  38162. ePKI Root Certification Authority
  38163. =================================
  38164. -----BEGIN CERTIFICATE-----
  38165. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  38166. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  38167. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  38168. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  38169. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  38170. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  38171. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  38172. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  38173. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  38174. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  38175. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  38176. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  38177. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  38178. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  38179. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  38180. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  38181. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  38182. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  38183. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  38184. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  38185. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  38186. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  38187. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  38188. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  38189. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  38190. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  38191. -----END CERTIFICATE-----
  38192. certSIGN ROOT CA
  38193. ================
  38194. -----BEGIN CERTIFICATE-----
  38195. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  38196. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  38197. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  38198. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  38199. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  38200. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  38201. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  38202. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  38203. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  38204. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  38205. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  38206. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  38207. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  38208. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  38209. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  38210. -----END CERTIFICATE-----
  38211. NetLock Arany (Class Gold) Főtanúsítvány
  38212. ========================================
  38213. -----BEGIN CERTIFICATE-----
  38214. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  38215. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  38216. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  38217. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  38218. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  38219. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  38220. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  38221. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  38222. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  38223. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  38224. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  38225. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  38226. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  38227. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  38228. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  38229. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  38230. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  38231. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  38232. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  38233. -----END CERTIFICATE-----
  38234. Hongkong Post Root CA 1
  38235. =======================
  38236. -----BEGIN CERTIFICATE-----
  38237. MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT
  38238. DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx
  38239. NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n
  38240. IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF
  38241. AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1
  38242. ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr
  38243. auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh
  38244. qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY
  38245. V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV
  38246. HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i
  38247. h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio
  38248. l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei
  38249. IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps
  38250. T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT
  38251. c4afU9hDDl3WY4JxHYB0yvbiAmvZWg==
  38252. -----END CERTIFICATE-----
  38253. SecureSign RootCA11
  38254. ===================
  38255. -----BEGIN CERTIFICATE-----
  38256. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  38257. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  38258. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  38259. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  38260. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  38261. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  38262. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  38263. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  38264. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  38265. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  38266. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  38267. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  38268. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  38269. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  38270. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  38271. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  38272. -----END CERTIFICATE-----
  38273. Microsec e-Szigno Root CA 2009
  38274. ==============================
  38275. -----BEGIN CERTIFICATE-----
  38276. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  38277. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  38278. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  38279. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  38280. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  38281. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  38282. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  38283. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  38284. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  38285. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  38286. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  38287. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  38288. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  38289. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  38290. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  38291. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  38292. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  38293. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  38294. LXpUq3DDfSJlgnCW
  38295. -----END CERTIFICATE-----
  38296. GlobalSign Root CA - R3
  38297. =======================
  38298. -----BEGIN CERTIFICATE-----
  38299. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  38300. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  38301. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  38302. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  38303. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  38304. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  38305. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  38306. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  38307. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  38308. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  38309. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  38310. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  38311. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  38312. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  38313. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  38314. kpeDMdmztcpHWD9f
  38315. -----END CERTIFICATE-----
  38316. Autoridad de Certificacion Firmaprofesional CIF A62634068
  38317. =========================================================
  38318. -----BEGIN CERTIFICATE-----
  38319. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  38320. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  38321. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  38322. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  38323. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  38324. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  38325. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  38326. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  38327. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  38328. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  38329. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  38330. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  38331. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  38332. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  38333. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  38334. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  38335. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  38336. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  38337. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  38338. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  38339. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  38340. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  38341. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  38342. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  38343. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  38344. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  38345. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  38346. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  38347. -----END CERTIFICATE-----
  38348. Izenpe.com
  38349. ==========
  38350. -----BEGIN CERTIFICATE-----
  38351. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  38352. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  38353. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  38354. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  38355. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  38356. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  38357. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  38358. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  38359. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  38360. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  38361. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  38362. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  38363. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  38364. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  38365. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  38366. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  38367. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  38368. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  38369. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  38370. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  38371. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  38372. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  38373. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  38374. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  38375. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  38376. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  38377. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  38378. -----END CERTIFICATE-----
  38379. Go Daddy Root Certificate Authority - G2
  38380. ========================================
  38381. -----BEGIN CERTIFICATE-----
  38382. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  38383. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  38384. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  38385. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  38386. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  38387. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  38388. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  38389. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  38390. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  38391. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  38392. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  38393. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  38394. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  38395. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  38396. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  38397. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  38398. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  38399. -----END CERTIFICATE-----
  38400. Starfield Root Certificate Authority - G2
  38401. =========================================
  38402. -----BEGIN CERTIFICATE-----
  38403. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  38404. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  38405. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  38406. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  38407. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  38408. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  38409. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  38410. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  38411. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  38412. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  38413. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  38414. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  38415. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  38416. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  38417. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  38418. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  38419. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  38420. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  38421. -----END CERTIFICATE-----
  38422. Starfield Services Root Certificate Authority - G2
  38423. ==================================================
  38424. -----BEGIN CERTIFICATE-----
  38425. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  38426. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  38427. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  38428. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  38429. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  38430. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  38431. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  38432. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  38433. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  38434. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  38435. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  38436. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  38437. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  38438. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  38439. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  38440. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  38441. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  38442. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  38443. -----END CERTIFICATE-----
  38444. AffirmTrust Commercial
  38445. ======================
  38446. -----BEGIN CERTIFICATE-----
  38447. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  38448. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  38449. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  38450. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  38451. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  38452. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  38453. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  38454. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  38455. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  38456. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  38457. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  38458. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  38459. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  38460. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  38461. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  38462. -----END CERTIFICATE-----
  38463. AffirmTrust Networking
  38464. ======================
  38465. -----BEGIN CERTIFICATE-----
  38466. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  38467. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  38468. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  38469. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  38470. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  38471. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  38472. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  38473. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  38474. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  38475. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  38476. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  38477. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  38478. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  38479. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  38480. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  38481. -----END CERTIFICATE-----
  38482. AffirmTrust Premium
  38483. ===================
  38484. -----BEGIN CERTIFICATE-----
  38485. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  38486. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  38487. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  38488. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  38489. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  38490. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  38491. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  38492. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  38493. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  38494. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  38495. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  38496. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  38497. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  38498. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  38499. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  38500. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  38501. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  38502. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  38503. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  38504. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  38505. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  38506. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  38507. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  38508. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  38509. -----END CERTIFICATE-----
  38510. AffirmTrust Premium ECC
  38511. =======================
  38512. -----BEGIN CERTIFICATE-----
  38513. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  38514. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  38515. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  38516. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  38517. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  38518. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  38519. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  38520. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  38521. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  38522. eQ==
  38523. -----END CERTIFICATE-----
  38524. Certum Trusted Network CA
  38525. =========================
  38526. -----BEGIN CERTIFICATE-----
  38527. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  38528. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  38529. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  38530. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  38531. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  38532. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  38533. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  38534. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  38535. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  38536. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  38537. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  38538. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  38539. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  38540. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  38541. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  38542. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  38543. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  38544. -----END CERTIFICATE-----
  38545. TWCA Root Certification Authority
  38546. =================================
  38547. -----BEGIN CERTIFICATE-----
  38548. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  38549. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  38550. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  38551. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  38552. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  38553. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  38554. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  38555. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  38556. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  38557. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  38558. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  38559. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  38560. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  38561. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  38562. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  38563. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  38564. -----END CERTIFICATE-----
  38565. Security Communication RootCA2
  38566. ==============================
  38567. -----BEGIN CERTIFICATE-----
  38568. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  38569. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  38570. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  38571. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  38572. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  38573. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  38574. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  38575. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  38576. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  38577. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  38578. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  38579. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  38580. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  38581. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  38582. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  38583. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  38584. -----END CERTIFICATE-----
  38585. EC-ACC
  38586. ======
  38587. -----BEGIN CERTIFICATE-----
  38588. MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE
  38589. BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w
  38590. ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD
  38591. VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE
  38592. CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT
  38593. BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7
  38594. MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt
  38595. SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl
  38596. Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh
  38597. cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND
  38598. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK
  38599. w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT
  38600. ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4
  38601. HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a
  38602. E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw
  38603. 0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E
  38604. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD
  38605. VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0
  38606. Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l
  38607. dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ
  38608. lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa
  38609. Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe
  38610. l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2
  38611. E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D
  38612. 5EI=
  38613. -----END CERTIFICATE-----
  38614. Hellenic Academic and Research Institutions RootCA 2011
  38615. =======================================================
  38616. -----BEGIN CERTIFICATE-----
  38617. MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT
  38618. O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y
  38619. aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  38620. IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT
  38621. AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  38622. IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo
  38623. IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  38624. AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI
  38625. 1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa
  38626. 71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u
  38627. 8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH
  38628. 3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/
  38629. MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8
  38630. MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu
  38631. b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt
  38632. XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8
  38633. TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD
  38634. /md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N
  38635. 7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4
  38636. -----END CERTIFICATE-----
  38637. Actalis Authentication Root CA
  38638. ==============================
  38639. -----BEGIN CERTIFICATE-----
  38640. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  38641. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  38642. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  38643. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  38644. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  38645. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  38646. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  38647. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  38648. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  38649. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  38650. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  38651. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  38652. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  38653. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  38654. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  38655. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  38656. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  38657. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  38658. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  38659. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  38660. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  38661. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  38662. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  38663. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  38664. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  38665. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  38666. -----END CERTIFICATE-----
  38667. Buypass Class 2 Root CA
  38668. =======================
  38669. -----BEGIN CERTIFICATE-----
  38670. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  38671. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  38672. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  38673. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  38674. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  38675. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  38676. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  38677. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  38678. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  38679. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  38680. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  38681. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  38682. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  38683. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  38684. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  38685. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  38686. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  38687. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  38688. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  38689. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  38690. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  38691. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  38692. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  38693. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  38694. rJgWVqA=
  38695. -----END CERTIFICATE-----
  38696. Buypass Class 3 Root CA
  38697. =======================
  38698. -----BEGIN CERTIFICATE-----
  38699. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  38700. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  38701. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  38702. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  38703. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  38704. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  38705. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  38706. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  38707. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  38708. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  38709. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  38710. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  38711. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  38712. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  38713. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  38714. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  38715. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  38716. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  38717. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  38718. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  38719. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  38720. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  38721. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  38722. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  38723. Cp/HuZc=
  38724. -----END CERTIFICATE-----
  38725. T-TeleSec GlobalRoot Class 3
  38726. ============================
  38727. -----BEGIN CERTIFICATE-----
  38728. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  38729. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  38730. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  38731. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  38732. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  38733. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  38734. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  38735. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  38736. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  38737. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  38738. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  38739. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  38740. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  38741. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  38742. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  38743. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  38744. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  38745. -----END CERTIFICATE-----
  38746. D-TRUST Root Class 3 CA 2 2009
  38747. ==============================
  38748. -----BEGIN CERTIFICATE-----
  38749. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  38750. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  38751. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  38752. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  38753. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  38754. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  38755. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  38756. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  38757. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  38758. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  38759. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  38760. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  38761. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  38762. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  38763. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  38764. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  38765. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  38766. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  38767. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  38768. -----END CERTIFICATE-----
  38769. D-TRUST Root Class 3 CA 2 EV 2009
  38770. =================================
  38771. -----BEGIN CERTIFICATE-----
  38772. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  38773. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  38774. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  38775. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  38776. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  38777. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  38778. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  38779. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  38780. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  38781. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  38782. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  38783. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  38784. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  38785. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  38786. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  38787. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  38788. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  38789. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  38790. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  38791. w9y4AyHqnxbxLFS1
  38792. -----END CERTIFICATE-----
  38793. CA Disig Root R2
  38794. ================
  38795. -----BEGIN CERTIFICATE-----
  38796. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  38797. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  38798. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  38799. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  38800. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  38801. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  38802. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  38803. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  38804. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  38805. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  38806. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  38807. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  38808. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  38809. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  38810. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  38811. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  38812. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  38813. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  38814. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  38815. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  38816. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  38817. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  38818. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  38819. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  38820. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  38821. -----END CERTIFICATE-----
  38822. ACCVRAIZ1
  38823. =========
  38824. -----BEGIN CERTIFICATE-----
  38825. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  38826. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  38827. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  38828. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  38829. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  38830. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  38831. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  38832. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  38833. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  38834. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  38835. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  38836. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  38837. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  38838. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  38839. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  38840. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  38841. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  38842. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  38843. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  38844. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  38845. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  38846. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  38847. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  38848. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  38849. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  38850. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  38851. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  38852. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  38853. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  38854. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  38855. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  38856. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  38857. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  38858. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  38859. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  38860. EfbRD0tVNEYqi4Y7
  38861. -----END CERTIFICATE-----
  38862. TWCA Global Root CA
  38863. ===================
  38864. -----BEGIN CERTIFICATE-----
  38865. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  38866. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  38867. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  38868. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  38869. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  38870. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  38871. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  38872. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  38873. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  38874. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  38875. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  38876. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  38877. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  38878. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  38879. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  38880. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  38881. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  38882. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  38883. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  38884. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  38885. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  38886. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  38887. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  38888. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  38889. -----END CERTIFICATE-----
  38890. TeliaSonera Root CA v1
  38891. ======================
  38892. -----BEGIN CERTIFICATE-----
  38893. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  38894. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  38895. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  38896. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  38897. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  38898. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  38899. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  38900. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  38901. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  38902. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  38903. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  38904. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  38905. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  38906. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  38907. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  38908. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  38909. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  38910. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  38911. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  38912. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  38913. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  38914. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  38915. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  38916. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  38917. -----END CERTIFICATE-----
  38918. E-Tugra Certification Authority
  38919. ===============================
  38920. -----BEGIN CERTIFICATE-----
  38921. MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w
  38922. DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls
  38923. ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN
  38924. ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw
  38925. NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx
  38926. QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl
  38927. cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD
  38928. DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  38929. MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd
  38930. hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K
  38931. CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g
  38932. ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ
  38933. BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0
  38934. E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz
  38935. rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq
  38936. jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn
  38937. rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5
  38938. dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB
  38939. /wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG
  38940. MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK
  38941. kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO
  38942. XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807
  38943. VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo
  38944. a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc
  38945. dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV
  38946. KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT
  38947. Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0
  38948. 8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G
  38949. C7TbO6Orb1wdtn7os4I07QZcJA==
  38950. -----END CERTIFICATE-----
  38951. T-TeleSec GlobalRoot Class 2
  38952. ============================
  38953. -----BEGIN CERTIFICATE-----
  38954. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  38955. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  38956. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  38957. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  38958. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  38959. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  38960. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  38961. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  38962. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  38963. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  38964. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  38965. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  38966. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  38967. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  38968. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  38969. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  38970. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  38971. -----END CERTIFICATE-----
  38972. Atos TrustedRoot 2011
  38973. =====================
  38974. -----BEGIN CERTIFICATE-----
  38975. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  38976. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  38977. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  38978. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  38979. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  38980. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  38981. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  38982. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  38983. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  38984. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  38985. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  38986. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  38987. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  38988. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  38989. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  38990. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  38991. -----END CERTIFICATE-----
  38992. QuoVadis Root CA 1 G3
  38993. =====================
  38994. -----BEGIN CERTIFICATE-----
  38995. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  38996. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  38997. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  38998. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  38999. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  39000. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  39001. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  39002. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  39003. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  39004. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  39005. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  39006. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  39007. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  39008. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  39009. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  39010. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  39011. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  39012. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  39013. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  39014. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  39015. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  39016. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  39017. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  39018. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  39019. hMJKzRwuJIczYOXD
  39020. -----END CERTIFICATE-----
  39021. QuoVadis Root CA 2 G3
  39022. =====================
  39023. -----BEGIN CERTIFICATE-----
  39024. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  39025. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  39026. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  39027. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  39028. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  39029. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  39030. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  39031. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  39032. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  39033. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  39034. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  39035. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  39036. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  39037. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  39038. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  39039. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  39040. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  39041. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  39042. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  39043. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  39044. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  39045. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  39046. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  39047. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  39048. O3jtZsSOeWmD3n+M
  39049. -----END CERTIFICATE-----
  39050. QuoVadis Root CA 3 G3
  39051. =====================
  39052. -----BEGIN CERTIFICATE-----
  39053. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  39054. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  39055. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  39056. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  39057. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  39058. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  39059. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  39060. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  39061. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  39062. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  39063. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  39064. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  39065. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  39066. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  39067. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  39068. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  39069. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  39070. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  39071. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  39072. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  39073. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  39074. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  39075. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  39076. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  39077. PpxxVJkES/1Y+Zj0
  39078. -----END CERTIFICATE-----
  39079. DigiCert Assured ID Root G2
  39080. ===========================
  39081. -----BEGIN CERTIFICATE-----
  39082. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  39083. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  39084. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  39085. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  39086. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  39087. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  39088. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  39089. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  39090. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  39091. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  39092. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  39093. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  39094. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  39095. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  39096. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  39097. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  39098. IhNzbM8m9Yop5w==
  39099. -----END CERTIFICATE-----
  39100. DigiCert Assured ID Root G3
  39101. ===========================
  39102. -----BEGIN CERTIFICATE-----
  39103. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  39104. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  39105. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  39106. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  39107. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  39108. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  39109. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  39110. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  39111. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  39112. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  39113. 1vUhZscv6pZjamVFkpUBtA==
  39114. -----END CERTIFICATE-----
  39115. DigiCert Global Root G2
  39116. =======================
  39117. -----BEGIN CERTIFICATE-----
  39118. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  39119. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  39120. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  39121. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  39122. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  39123. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  39124. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  39125. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  39126. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  39127. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  39128. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  39129. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  39130. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  39131. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  39132. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  39133. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  39134. MrY=
  39135. -----END CERTIFICATE-----
  39136. DigiCert Global Root G3
  39137. =======================
  39138. -----BEGIN CERTIFICATE-----
  39139. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  39140. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  39141. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  39142. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  39143. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  39144. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  39145. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  39146. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  39147. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  39148. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  39149. VOKa5Vt8sycX
  39150. -----END CERTIFICATE-----
  39151. DigiCert Trusted Root G4
  39152. ========================
  39153. -----BEGIN CERTIFICATE-----
  39154. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  39155. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  39156. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  39157. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  39158. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  39159. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  39160. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  39161. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  39162. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  39163. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  39164. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  39165. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  39166. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  39167. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  39168. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  39169. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  39170. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  39171. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  39172. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  39173. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  39174. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  39175. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  39176. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  39177. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  39178. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  39179. 82Z+
  39180. -----END CERTIFICATE-----
  39181. COMODO RSA Certification Authority
  39182. ==================================
  39183. -----BEGIN CERTIFICATE-----
  39184. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  39185. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  39186. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  39187. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  39188. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  39189. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  39190. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  39191. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  39192. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  39193. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  39194. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  39195. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  39196. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  39197. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  39198. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  39199. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  39200. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  39201. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  39202. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  39203. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  39204. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  39205. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  39206. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  39207. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  39208. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  39209. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  39210. LaZRfyHBNVOFBkpdn627G190
  39211. -----END CERTIFICATE-----
  39212. USERTrust RSA Certification Authority
  39213. =====================================
  39214. -----BEGIN CERTIFICATE-----
  39215. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  39216. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  39217. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  39218. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  39219. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  39220. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  39221. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  39222. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  39223. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  39224. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  39225. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  39226. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  39227. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  39228. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  39229. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  39230. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  39231. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  39232. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  39233. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  39234. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  39235. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  39236. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  39237. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  39238. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  39239. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  39240. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  39241. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  39242. -----END CERTIFICATE-----
  39243. USERTrust ECC Certification Authority
  39244. =====================================
  39245. -----BEGIN CERTIFICATE-----
  39246. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  39247. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  39248. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  39249. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  39250. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  39251. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  39252. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  39253. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  39254. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  39255. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  39256. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  39257. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  39258. -----END CERTIFICATE-----
  39259. GlobalSign ECC Root CA - R4
  39260. ===========================
  39261. -----BEGIN CERTIFICATE-----
  39262. MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
  39263. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  39264. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  39265. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  39266. EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
  39267. OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
  39268. AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
  39269. MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
  39270. JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
  39271. -----END CERTIFICATE-----
  39272. GlobalSign ECC Root CA - R5
  39273. ===========================
  39274. -----BEGIN CERTIFICATE-----
  39275. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  39276. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  39277. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  39278. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  39279. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  39280. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  39281. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  39282. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  39283. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  39284. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  39285. -----END CERTIFICATE-----
  39286. Staat der Nederlanden EV Root CA
  39287. ================================
  39288. -----BEGIN CERTIFICATE-----
  39289. MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
  39290. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  39291. RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
  39292. MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
  39293. cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
  39294. SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
  39295. O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
  39296. 0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
  39297. Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
  39298. XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
  39299. 08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
  39300. 0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd
  39301. 74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx
  39302. fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC
  39303. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa
  39304. ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI
  39305. eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu
  39306. c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq
  39307. 5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN
  39308. b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN
  39309. f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi
  39310. 5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4
  39311. WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK
  39312. DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy
  39313. eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
  39314. -----END CERTIFICATE-----
  39315. IdenTrust Commercial Root CA 1
  39316. ==============================
  39317. -----BEGIN CERTIFICATE-----
  39318. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  39319. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  39320. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  39321. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  39322. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  39323. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  39324. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  39325. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  39326. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  39327. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  39328. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  39329. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  39330. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  39331. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  39332. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  39333. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  39334. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  39335. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  39336. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  39337. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  39338. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  39339. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  39340. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  39341. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  39342. cGzM7vRX+Bi6hG6H
  39343. -----END CERTIFICATE-----
  39344. IdenTrust Public Sector Root CA 1
  39345. =================================
  39346. -----BEGIN CERTIFICATE-----
  39347. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  39348. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  39349. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  39350. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  39351. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  39352. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  39353. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  39354. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  39355. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  39356. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  39357. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  39358. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  39359. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  39360. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  39361. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  39362. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  39363. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  39364. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  39365. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  39366. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  39367. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  39368. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  39369. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  39370. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  39371. 3Wl9af0AVqW3rLatt8o+Ae+c
  39372. -----END CERTIFICATE-----
  39373. Entrust Root Certification Authority - G2
  39374. =========================================
  39375. -----BEGIN CERTIFICATE-----
  39376. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  39377. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  39378. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  39379. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  39380. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  39381. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  39382. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  39383. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  39384. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  39385. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  39386. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  39387. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  39388. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  39389. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  39390. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  39391. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  39392. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  39393. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  39394. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  39395. e4pIb4tF9g==
  39396. -----END CERTIFICATE-----
  39397. Entrust Root Certification Authority - EC1
  39398. ==========================================
  39399. -----BEGIN CERTIFICATE-----
  39400. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  39401. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  39402. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  39403. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  39404. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  39405. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  39406. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  39407. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  39408. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  39409. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  39410. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  39411. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  39412. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  39413. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  39414. -----END CERTIFICATE-----
  39415. CFCA EV ROOT
  39416. ============
  39417. -----BEGIN CERTIFICATE-----
  39418. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  39419. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  39420. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  39421. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  39422. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  39423. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  39424. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  39425. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  39426. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  39427. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  39428. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  39429. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  39430. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  39431. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  39432. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  39433. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  39434. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  39435. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  39436. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  39437. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  39438. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  39439. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  39440. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  39441. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  39442. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  39443. -----END CERTIFICATE-----
  39444. OISTE WISeKey Global Root GB CA
  39445. ===============================
  39446. -----BEGIN CERTIFICATE-----
  39447. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  39448. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  39449. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  39450. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  39451. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  39452. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  39453. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  39454. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  39455. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  39456. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  39457. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  39458. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  39459. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  39460. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  39461. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  39462. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  39463. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  39464. -----END CERTIFICATE-----
  39465. SZAFIR ROOT CA2
  39466. ===============
  39467. -----BEGIN CERTIFICATE-----
  39468. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  39469. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  39470. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  39471. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  39472. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  39473. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  39474. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  39475. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  39476. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  39477. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  39478. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  39479. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  39480. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  39481. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  39482. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  39483. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  39484. -----END CERTIFICATE-----
  39485. Certum Trusted Network CA 2
  39486. ===========================
  39487. -----BEGIN CERTIFICATE-----
  39488. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  39489. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  39490. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  39491. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  39492. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  39493. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  39494. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  39495. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  39496. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  39497. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  39498. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  39499. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  39500. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  39501. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  39502. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  39503. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  39504. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  39505. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  39506. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  39507. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  39508. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  39509. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  39510. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  39511. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  39512. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  39513. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  39514. zAYspsbiDrW5viSP
  39515. -----END CERTIFICATE-----
  39516. Hellenic Academic and Research Institutions RootCA 2015
  39517. =======================================================
  39518. -----BEGIN CERTIFICATE-----
  39519. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  39520. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  39521. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  39522. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  39523. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  39524. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  39525. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  39526. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  39527. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  39528. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  39529. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  39530. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  39531. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  39532. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  39533. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  39534. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  39535. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  39536. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  39537. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  39538. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  39539. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  39540. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  39541. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  39542. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  39543. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  39544. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  39545. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  39546. p/UsQu0yrbYhnr68
  39547. -----END CERTIFICATE-----
  39548. Hellenic Academic and Research Institutions ECC RootCA 2015
  39549. ===========================================================
  39550. -----BEGIN CERTIFICATE-----
  39551. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  39552. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  39553. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  39554. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  39555. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  39556. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  39557. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  39558. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  39559. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  39560. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  39561. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  39562. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  39563. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  39564. -----END CERTIFICATE-----
  39565. ISRG Root X1
  39566. ============
  39567. -----BEGIN CERTIFICATE-----
  39568. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  39569. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  39570. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  39571. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  39572. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  39573. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  39574. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  39575. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  39576. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  39577. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  39578. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  39579. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  39580. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  39581. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  39582. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  39583. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  39584. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  39585. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  39586. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  39587. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  39588. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  39589. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  39590. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  39591. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  39592. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  39593. -----END CERTIFICATE-----
  39594. AC RAIZ FNMT-RCM
  39595. ================
  39596. -----BEGIN CERTIFICATE-----
  39597. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  39598. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  39599. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  39600. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  39601. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  39602. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  39603. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  39604. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  39605. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  39606. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  39607. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  39608. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  39609. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  39610. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  39611. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  39612. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  39613. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  39614. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  39615. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  39616. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  39617. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  39618. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  39619. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  39620. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  39621. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  39622. -----END CERTIFICATE-----
  39623. Amazon Root CA 1
  39624. ================
  39625. -----BEGIN CERTIFICATE-----
  39626. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  39627. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  39628. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  39629. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  39630. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  39631. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  39632. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  39633. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  39634. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  39635. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  39636. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  39637. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  39638. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  39639. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  39640. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  39641. -----END CERTIFICATE-----
  39642. Amazon Root CA 2
  39643. ================
  39644. -----BEGIN CERTIFICATE-----
  39645. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  39646. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  39647. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  39648. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  39649. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  39650. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  39651. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  39652. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  39653. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  39654. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  39655. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  39656. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  39657. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  39658. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  39659. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  39660. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  39661. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  39662. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  39663. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  39664. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  39665. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  39666. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  39667. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  39668. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  39669. -----END CERTIFICATE-----
  39670. Amazon Root CA 3
  39671. ================
  39672. -----BEGIN CERTIFICATE-----
  39673. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  39674. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  39675. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  39676. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  39677. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  39678. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  39679. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  39680. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  39681. -----END CERTIFICATE-----
  39682. Amazon Root CA 4
  39683. ================
  39684. -----BEGIN CERTIFICATE-----
  39685. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  39686. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  39687. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  39688. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  39689. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  39690. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  39691. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  39692. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  39693. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  39694. -----END CERTIFICATE-----
  39695. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  39696. =============================================
  39697. -----BEGIN CERTIFICATE-----
  39698. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  39699. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  39700. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  39701. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  39702. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  39703. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  39704. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  39705. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  39706. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  39707. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  39708. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  39709. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  39710. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  39711. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  39712. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  39713. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  39714. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  39715. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  39716. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  39717. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  39718. -----END CERTIFICATE-----
  39719. GDCA TrustAUTH R5 ROOT
  39720. ======================
  39721. -----BEGIN CERTIFICATE-----
  39722. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  39723. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  39724. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  39725. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  39726. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  39727. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  39728. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  39729. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  39730. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  39731. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  39732. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  39733. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  39734. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  39735. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  39736. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  39737. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  39738. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  39739. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  39740. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  39741. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  39742. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  39743. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  39744. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  39745. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  39746. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  39747. -----END CERTIFICATE-----
  39748. TrustCor RootCert CA-1
  39749. ======================
  39750. -----BEGIN CERTIFICATE-----
  39751. MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYDVQQGEwJQQTEP
  39752. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  39753. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  39754. dHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkx
  39755. MjMxMTcyMzE2WjCBpDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFu
  39756. YW1hIENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUGA1UECwwe
  39757. VHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZUcnVzdENvciBSb290Q2Vy
  39758. dCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv463leLCJhJrMxnHQFgKq1mq
  39759. jQCj/IDHUHuO1CAmujIS2CNUSSUQIpidRtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4
  39760. pQa81QBeCQryJ3pS/C3Vseq0iWEk8xoT26nPUu0MJLq5nux+AHT6k61sKZKuUbS701e/s/OojZz0
  39761. JEsq1pme9J7+wH5COucLlVPat2gOkEz7cD+PSiyU8ybdY2mplNgQTsVHCJCZGxdNuWxu72CVEY4h
  39762. gLW9oHPY0LJ3xEXqWib7ZnZ2+AYfYW0PVcWDtxBWcgYHpfOxGgMFZA6dWorWhnAbJN7+KIor0Gqw
  39763. /Hqi3LJ5DotlDwIDAQABo2MwYTAdBgNVHQ4EFgQU7mtJPHo/DeOxCbeKyKsZn3MzUOcwHwYDVR0j
  39764. BBgwFoAU7mtJPHo/DeOxCbeKyKsZn3MzUOcwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  39765. AYYwDQYJKoZIhvcNAQELBQADggEBACUY1JGPE+6PHh0RU9otRCkZoB5rMZ5NDp6tPVxBb5UrJKF5
  39766. mDo4Nvu7Zp5I/5CQ7z3UuJu0h3U/IJvOcs+hVcFNZKIZBqEHMwwLKeXx6quj7LUKdJDHfXLy11yf
  39767. ke+Ri7fc7Waiz45mO7yfOgLgJ90WmMCV1Aqk5IGadZQ1nJBfiDcGrVmVCrDRZ9MZyonnMlo2HD6C
  39768. qFqTvsbQZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djtsL1Ac59v2Z3kf9YKVmgenFK+P
  39769. 3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdNzl/HHk484IkzlQsPpTLWPFp5LBk=
  39770. -----END CERTIFICATE-----
  39771. TrustCor RootCert CA-2
  39772. ======================
  39773. -----BEGIN CERTIFICATE-----
  39774. MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNVBAYTAlBBMQ8w
  39775. DQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQwIgYDVQQKDBtUcnVzdENvciBT
  39776. eXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0
  39777. eTEfMB0GA1UEAwwWVHJ1c3RDb3IgUm9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEy
  39778. MzExNzI2MzlaMIGkMQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5h
  39779. bWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U
  39780. cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0
  39781. IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnIG7CKqJiJJWQdsg4foDSq8Gb
  39782. ZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9Nk
  39783. RvRUqdw6VC0xK5mC8tkq1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1
  39784. oYxOdqHp2yqlO/rOsP9+aij9JxzIsekp8VduZLTQwRVtDr4uDkbIXvRR/u8OYzo7cbrPb1nKDOOb
  39785. XUm4TOJXsZiKQlecdu/vvdFoqNL0Cbt3Nb4lggjEFixEIFapRBF37120Hapeaz6LMvYHL1cEksr1
  39786. /p3C6eizjkxLAjHZ5DxIgif3GIJ2SDpxsROhOdUuxTTCHWKF3wP+TfSvPd9cW436cOGlfifHhi5q
  39787. jxLGhF5DUVCcGZt45vz27Ud+ez1m7xMTiF88oWP7+ayHNZ/zgp6kPwqcMWmLmaSISo5uZk3vFsQP
  39788. eSghYA2FFn3XVDjxklb9tTNMg9zXEJ9L/cb4Qr26fHMC4P99zVvh1Kxhe1fVSntb1IVYJ12/+Ctg
  39789. rKAmrhQhJ8Z3mjOAPF5GP/fDsaOGM8boXg25NSyqRsGFAnWAoOsk+xWq5Gd/bnc/9ASKL3x74xdh
  39790. 8N0JqSDIvgmk0H5Ew7IwSjiqqewYmgeCK9u4nBit2uBGF6zPXQIDAQABo2MwYTAdBgNVHQ4EFgQU
  39791. 2f4hQG6UnrybPZx9mCAZ5YwwYrIwHwYDVR0jBBgwFoAU2f4hQG6UnrybPZx9mCAZ5YwwYrIwDwYD
  39792. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAJ5Fngw7tu/h
  39793. Osh80QA9z+LqBrWyOrsGS2h60COXdKcs8AjYeVrXWoSK2BKaG9l9XE1wxaX5q+WjiYndAfrs3fnp
  39794. kpfbsEZC89NiqpX+MWcUaViQCqoL7jcjx1BRtPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv
  39795. 2wnL/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RXCI/hOWB3
  39796. S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYaZH9bDTMJBzN7Bj8RpFxw
  39797. PIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dv
  39798. DDqPys/cA8GiCcjl/YBeyGBCARsaU1q7N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYU
  39799. RpFHmygk71dSTlxCnKr3Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANE
  39800. xdqtvArBAs8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp5KeX
  39801. RKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu1uwJ
  39802. -----END CERTIFICATE-----
  39803. TrustCor ECA-1
  39804. ==============
  39805. -----BEGIN CERTIFICATE-----
  39806. MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYDVQQGEwJQQTEP
  39807. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  39808. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  39809. dHkxFzAVBgNVBAMMDlRydXN0Q29yIEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3Mjgw
  39810. N1owgZwxCzAJBgNVBAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5
  39811. MSQwIgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29y
  39812. IENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3IgRUNBLTEwggEiMA0GCSqG
  39813. SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb3w9U73NjKYKtR8aja+3+XzP4Q1HpGjOR
  39814. MRegdMTUpwHmspI+ap3tDvl0mEDTPwOABoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23
  39815. xFUfJ3zSCNV2HykVh0A53ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmc
  39816. p0yJF4OuowReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/wZ0+
  39817. fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZFZtS6mFjBAgMBAAGj
  39818. YzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAfBgNVHSMEGDAWgBREnkj1zG1I1KBL
  39819. f/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
  39820. AAOCAQEABT41XBVwm8nHc2FvcivUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u
  39821. /ukZMjgDfxT2AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F
  39822. hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50soIipX1TH0Xs
  39823. J5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BIWJZpTdwHjFGTot+fDz2LYLSC
  39824. jaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1WitJ/X5g==
  39825. -----END CERTIFICATE-----
  39826. SSL.com Root Certification Authority RSA
  39827. ========================================
  39828. -----BEGIN CERTIFICATE-----
  39829. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  39830. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  39831. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  39832. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  39833. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  39834. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  39835. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  39836. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  39837. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  39838. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  39839. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  39840. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  39841. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  39842. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  39843. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  39844. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  39845. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  39846. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  39847. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  39848. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  39849. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  39850. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  39851. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  39852. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  39853. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  39854. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  39855. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  39856. -----END CERTIFICATE-----
  39857. SSL.com Root Certification Authority ECC
  39858. ========================================
  39859. -----BEGIN CERTIFICATE-----
  39860. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  39861. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  39862. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  39863. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  39864. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  39865. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  39866. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  39867. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  39868. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  39869. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  39870. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  39871. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  39872. -----END CERTIFICATE-----
  39873. SSL.com EV Root Certification Authority RSA R2
  39874. ==============================================
  39875. -----BEGIN CERTIFICATE-----
  39876. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  39877. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  39878. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  39879. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  39880. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  39881. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  39882. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  39883. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  39884. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  39885. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  39886. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  39887. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  39888. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  39889. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  39890. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  39891. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  39892. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  39893. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  39894. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  39895. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  39896. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  39897. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  39898. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  39899. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  39900. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  39901. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  39902. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  39903. -----END CERTIFICATE-----
  39904. SSL.com EV Root Certification Authority ECC
  39905. ===========================================
  39906. -----BEGIN CERTIFICATE-----
  39907. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  39908. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  39909. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  39910. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  39911. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  39912. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  39913. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  39914. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  39915. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  39916. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  39917. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  39918. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  39919. -----END CERTIFICATE-----
  39920. GlobalSign Root CA - R6
  39921. =======================
  39922. -----BEGIN CERTIFICATE-----
  39923. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  39924. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  39925. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  39926. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  39927. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  39928. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  39929. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  39930. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  39931. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  39932. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  39933. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  39934. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  39935. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  39936. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  39937. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  39938. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  39939. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  39940. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  39941. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  39942. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  39943. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  39944. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  39945. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  39946. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  39947. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  39948. -----END CERTIFICATE-----
  39949. OISTE WISeKey Global Root GC CA
  39950. ===============================
  39951. -----BEGIN CERTIFICATE-----
  39952. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  39953. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  39954. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  39955. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  39956. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  39957. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  39958. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  39959. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  39960. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  39961. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  39962. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  39963. -----END CERTIFICATE-----
  39964. GTS Root R1
  39965. ===========
  39966. -----BEGIN CERTIFICATE-----
  39967. MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  39968. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  39969. b3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  39970. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIi
  39971. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx
  39972. 9vaMf/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7r
  39973. aKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnW
  39974. r4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqM
  39975. LnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly
  39976. 4cpk9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr
  39977. 06zqkUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92
  39978. wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om
  39979. 3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNu
  39980. JLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  39981. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEM
  39982. BQADggIBADiWCu49tJYeX++dnAsznyvgyv3SjgofQXSlfKqE1OXyHuY3UjKcC9FhHb8owbZEKTV1
  39983. d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6ZXPYfcX3v73sv
  39984. fuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZRgyFmxhE+885H7pwoHyXa/6xm
  39985. ld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9b
  39986. gsiG1eGZbYwE8na6SfZu6W0eX6DvJ4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq
  39987. 4BjFbkerQUIpm/ZgDdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWEr
  39988. tXvM+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyyF62ARPBo
  39989. pY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9SQ98POyDGCBDTtWTurQ0
  39990. sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdwsE3PYJ/HQcu51OyLemGhmW/HGY0dVHLql
  39991. CFF1pkgl
  39992. -----END CERTIFICATE-----
  39993. GTS Root R2
  39994. ===========
  39995. -----BEGIN CERTIFICATE-----
  39996. MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  39997. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  39998. b3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  39999. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIi
  40000. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTuk
  40001. k3LvCvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo
  40002. 7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWI
  40003. m8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5Gm
  40004. dFrS+LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbu
  40005. ak7MkogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscsz
  40006. cTJGr61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RW
  40007. Ir9qS34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73Vululycsl
  40008. aVNVJ1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy
  40009. 5okLdWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  40010. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEM
  40011. BQADggIBALZp8KZ3/p7uC4Gt4cCpx/k1HUCCq+YEtN/L9x0Pg/B+E02NjO7jMyLDOfxA325BS0JT
  40012. vhaI8dI4XsRomRyYUpOM52jtG2pzegVATX9lO9ZY8c6DR2Dj/5epnGB3GFW1fgiTz9D2PGcDFWEJ
  40013. +YF59exTpJ/JjwGLc8R3dtyDovUMSRqodt6Sm2T4syzFJ9MHwAiApJiS4wGWAqoC7o87xdFtCjMw
  40014. c3i5T1QWvwsHoaRc5svJXISPD+AVdyx+Jn7axEvbpxZ3B7DNdehyQtaVhJ2Gg/LkkM0JR9SLA3Da
  40015. WsYDQvTtN6LwG1BUSw7YhN4ZKJmBR64JGz9I0cNv4rBgF/XuIwKl2gBbbZCr7qLpGzvpx0QnRY5r
  40016. n/WkhLx3+WuXrD5RRaIRpsyF7gpo8j5QOHokYh4XIDdtak23CZvJ/KRY9bb7nE4Yu5UC56Gtmwfu
  40017. Nmsk0jmGwZODUNKBRqhfYlcsu2xkiAhu7xNUX90txGdj08+JN7+dIPT7eoOboB6BAFDC5AwiWVIQ
  40018. 7UNWhwD4FFKnHYuTjKJNRn8nxnGbJN7k2oaLDX5rIMHAnuFl2GqjpuiFizoHCBy69Y9Vmhh1fuXs
  40019. gWbRIXOhNUQLgD1bnF5vKheW0YMjiGZt5obicDIvUiLnyOd/xCxgXS/Dr55FBcOEArf9LAhST4Ld
  40020. o/DUhgkC
  40021. -----END CERTIFICATE-----
  40022. GTS Root R3
  40023. ===========
  40024. -----BEGIN CERTIFICATE-----
  40025. MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  40026. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  40027. UjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  40028. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcq
  40029. hkjOPQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUU
  40030. Rout736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24Cej
  40031. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP
  40032. 0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFukfCPAlaUs3L6JbyO5o91lAFJekazInXJ0
  40033. glMLfalAvWhgxeG4VDvBNhcl2MG9AjEAnjWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOa
  40034. KaqW04MjyaR7YbPMAuhd
  40035. -----END CERTIFICATE-----
  40036. GTS Root R4
  40037. ===========
  40038. -----BEGIN CERTIFICATE-----
  40039. MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  40040. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  40041. UjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  40042. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcq
  40043. hkjOPQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa
  40044. 6zzuhXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqj
  40045. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV
  40046. 2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0CMRw3J5QdCHojXohw0+WbhXRIjVhLfoI
  40047. N+4Zba3bssx9BzT1YBkstTTZbyACMANxsbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11x
  40048. zPKwTdb+mciUqXWi4w==
  40049. -----END CERTIFICATE-----
  40050. UCA Global G2 Root
  40051. ==================
  40052. -----BEGIN CERTIFICATE-----
  40053. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  40054. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  40055. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  40056. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  40057. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  40058. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  40059. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  40060. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  40061. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  40062. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  40063. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  40064. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  40065. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  40066. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  40067. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  40068. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  40069. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  40070. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  40071. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  40072. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  40073. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  40074. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  40075. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  40076. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  40077. -----END CERTIFICATE-----
  40078. UCA Extended Validation Root
  40079. ============================
  40080. -----BEGIN CERTIFICATE-----
  40081. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  40082. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  40083. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  40084. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  40085. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  40086. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  40087. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  40088. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  40089. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  40090. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  40091. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  40092. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  40093. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  40094. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  40095. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  40096. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  40097. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  40098. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  40099. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  40100. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  40101. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  40102. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  40103. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  40104. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  40105. dhh2n1ax
  40106. -----END CERTIFICATE-----
  40107. Certigna Root CA
  40108. ================
  40109. -----BEGIN CERTIFICATE-----
  40110. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  40111. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  40112. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  40113. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  40114. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  40115. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  40116. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  40117. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  40118. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  40119. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  40120. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  40121. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  40122. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  40123. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  40124. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  40125. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  40126. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  40127. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  40128. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  40129. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  40130. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  40131. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  40132. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  40133. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  40134. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  40135. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  40136. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  40137. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  40138. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  40139. -----END CERTIFICATE-----
  40140. emSign Root CA - G1
  40141. ===================
  40142. -----BEGIN CERTIFICATE-----
  40143. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  40144. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  40145. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  40146. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  40147. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  40148. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  40149. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  40150. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  40151. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  40152. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  40153. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  40154. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  40155. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  40156. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  40157. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  40158. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  40159. iN66zB+Afko=
  40160. -----END CERTIFICATE-----
  40161. emSign ECC Root CA - G3
  40162. =======================
  40163. -----BEGIN CERTIFICATE-----
  40164. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  40165. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  40166. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  40167. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  40168. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  40169. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  40170. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  40171. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  40172. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  40173. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  40174. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  40175. -----END CERTIFICATE-----
  40176. emSign Root CA - C1
  40177. ===================
  40178. -----BEGIN CERTIFICATE-----
  40179. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  40180. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  40181. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  40182. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  40183. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  40184. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  40185. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  40186. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  40187. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  40188. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  40189. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  40190. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  40191. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  40192. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  40193. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  40194. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  40195. -----END CERTIFICATE-----
  40196. emSign ECC Root CA - C3
  40197. =======================
  40198. -----BEGIN CERTIFICATE-----
  40199. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  40200. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  40201. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  40202. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  40203. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  40204. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  40205. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  40206. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  40207. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  40208. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  40209. -----END CERTIFICATE-----
  40210. Hongkong Post Root CA 3
  40211. =======================
  40212. -----BEGIN CERTIFICATE-----
  40213. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  40214. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  40215. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  40216. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  40217. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  40218. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  40219. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  40220. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  40221. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  40222. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  40223. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  40224. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  40225. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  40226. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  40227. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  40228. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  40229. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  40230. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  40231. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  40232. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  40233. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  40234. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  40235. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  40236. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  40237. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  40238. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  40239. dBb9HxEGmpv0
  40240. -----END CERTIFICATE-----
  40241. Entrust Root Certification Authority - G4
  40242. =========================================
  40243. -----BEGIN CERTIFICATE-----
  40244. MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
  40245. BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
  40246. bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
  40247. dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1
  40248. dGhvcml0eSAtIEc0MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYT
  40249. AlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0
  40250. L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhv
  40251. cml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhv
  40252. cml0eSAtIEc0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3D
  40253. umSXbcr3DbVZwbPLqGgZ2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV
  40254. 3imz/f3ET+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j5pds
  40255. 8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAMC1rlLAHGVK/XqsEQ
  40256. e9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73TDtTUXm6Hnmo9RR3RXRv06QqsYJn7
  40257. ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNXwbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5X
  40258. xNMhIWNlUpEbsZmOeX7m640A2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV
  40259. 7rtNOzK+mndmnqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
  40260. dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwlN4y6mACXi0mW
  40261. Hv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNjc0kCAwEAAaNCMEAwDwYDVR0T
  40262. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9n
  40263. MA0GCSqGSIb3DQEBCwUAA4ICAQAS5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4Q
  40264. jbRaZIxowLByQzTSGwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht
  40265. 7LGrhFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/B7NTeLUK
  40266. YvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uIAeV8KEsD+UmDfLJ/fOPt
  40267. jqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbwH5Lk6rWS02FREAutp9lfx1/cH6NcjKF+
  40268. m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKW
  40269. RGhXxNUzzxkvFMSUHHuk2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjA
  40270. JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G
  40271. +TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuYn/PIjhs4ViFqUZPT
  40272. kcpG2om3PVODLAgfi49T3f+sHw==
  40273. -----END CERTIFICATE-----
  40274. Microsoft ECC Root Certificate Authority 2017
  40275. =============================================
  40276. -----BEGIN CERTIFICATE-----
  40277. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  40278. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  40279. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  40280. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  40281. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  40282. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  40283. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  40284. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  40285. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  40286. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  40287. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  40288. -----END CERTIFICATE-----
  40289. Microsoft RSA Root Certificate Authority 2017
  40290. =============================================
  40291. -----BEGIN CERTIFICATE-----
  40292. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  40293. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  40294. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  40295. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  40296. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  40297. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  40298. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  40299. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  40300. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  40301. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  40302. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  40303. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  40304. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  40305. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  40306. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  40307. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  40308. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  40309. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  40310. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  40311. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  40312. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  40313. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  40314. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  40315. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  40316. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  40317. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  40318. -----END CERTIFICATE-----
  40319. e-Szigno Root CA 2017
  40320. =====================
  40321. -----BEGIN CERTIFICATE-----
  40322. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  40323. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  40324. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  40325. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  40326. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  40327. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  40328. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  40329. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  40330. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  40331. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  40332. svxyqltZ+efcMQ==
  40333. -----END CERTIFICATE-----
  40334. certSIGN Root CA G2
  40335. ===================
  40336. -----BEGIN CERTIFICATE-----
  40337. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  40338. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  40339. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  40340. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  40341. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  40342. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  40343. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  40344. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  40345. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  40346. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  40347. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  40348. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  40349. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  40350. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  40351. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  40352. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  40353. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  40354. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  40355. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  40356. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  40357. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  40358. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  40359. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  40360. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  40361. -----END CERTIFICATE-----
  40362. Trustwave Global Certification Authority
  40363. ========================================
  40364. -----BEGIN CERTIFICATE-----
  40365. MIIF2jCCA8KgAwIBAgIMBfcOhtpJ80Y1LrqyMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJV
  40366. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  40367. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  40368. IEF1dGhvcml0eTAeFw0xNzA4MjMxOTM0MTJaFw00MjA4MjMxOTM0MTJaMIGIMQswCQYDVQQGEwJV
  40369. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  40370. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  40371. IEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALldUShLPDeS0YLOvR29
  40372. zd24q88KPuFd5dyqCblXAj7mY2Hf8g+CY66j96xz0XznswuvCAAJWX/NKSqIk4cXGIDtiLK0thAf
  40373. LdZfVaITXdHG6wZWiYj+rDKd/VzDBcdu7oaJuogDnXIhhpCujwOl3J+IKMujkkkP7NAP4m1ET4Bq
  40374. stTnoApTAbqOl5F2brz81Ws25kCI1nsvXwXoLG0R8+eyvpJETNKXpP7ScoFDB5zpET71ixpZfR9o
  40375. WN0EACyW80OzfpgZdNmcc9kYvkHHNHnZ9GLCQ7mzJ7Aiy/k9UscwR7PJPrhq4ufogXBeQotPJqX+
  40376. OsIgbrv4Fo7NDKm0G2x2EOFYeUY+VM6AqFcJNykbmROPDMjWLBz7BegIlT1lRtzuzWniTY+HKE40
  40377. Cz7PFNm73bZQmq131BnW2hqIyE4bJ3XYsgjxroMwuREOzYfwhI0Vcnyh78zyiGG69Gm7DIwLdVcE
  40378. uE4qFC49DxweMqZiNu5m4iK4BUBjECLzMx10coos9TkpoNPnG4CELcU9402x/RpvumUHO1jsQkUm
  40379. +9jaJXLE9gCxInm943xZYkqcBW89zubWR2OZxiRvchLIrH+QtAuRcOi35hYQcRfO3gZPSEF9NUqj
  40380. ifLJS3tBEW1ntwiYTOURGa5CgNz7kAXU+FDKvuStx8KU1xad5hePrzb7AgMBAAGjQjBAMA8GA1Ud
  40381. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFJngGWcNYtt2s9o9uFvo/ULSMQ6HMA4GA1UdDwEB/wQEAwIB
  40382. BjANBgkqhkiG9w0BAQsFAAOCAgEAmHNw4rDT7TnsTGDZqRKGFx6W0OhUKDtkLSGm+J1WE2pIPU/H
  40383. PinbbViDVD2HfSMF1OQc3Og4ZYbFdada2zUFvXfeuyk3QAUHw5RSn8pk3fEbK9xGChACMf1KaA0H
  40384. ZJDmHvUqoai7PF35owgLEQzxPy0QlG/+4jSHg9bP5Rs1bdID4bANqKCqRieCNqcVtgimQlRXtpla
  40385. 4gt5kNdXElE1GYhBaCXUNxeEFfsBctyV3lImIJgm4nb1J2/6ADtKYdkNy1GTKv0WBpanI5ojSP5R
  40386. vbbEsLFUzt5sQa0WZ37b/TjNuThOssFgy50X31ieemKyJo90lZvkWx3SD92YHJtZuSPTMaCm/zjd
  40387. zyBP6VhWOmfD0faZmZ26NraAL4hHT4a/RDqA5Dccprrql5gR0IRiR2Qequ5AvzSxnI9O4fKSTx+O
  40388. 856X3vOmeWqJcU9LJxdI/uz0UA9PSX3MReO9ekDFQdxhVicGaeVyQYHTtgGJoC86cnn+OjC/QezH
  40389. Yj6RS8fZMXZC+fc8Y+wmjHMMfRod6qh8h6jCJ3zhM0EPz8/8AKAigJ5Kp28AsEFFtyLKaEjFQqKu
  40390. 3R3y4G5OBVixwJAWKqQ9EEC+j2Jjg6mcgn0tAumDMHzLJ8n9HmYAsC7TIS+OMxZsmO0QqAfWzJPP
  40391. 29FpHOTKyeC2nOnOcXHebD8WpHk=
  40392. -----END CERTIFICATE-----
  40393. Trustwave Global ECC P256 Certification Authority
  40394. =================================================
  40395. -----BEGIN CERTIFICATE-----
  40396. MIICYDCCAgegAwIBAgIMDWpfCD8oXD5Rld9dMAoGCCqGSM49BAMCMIGRMQswCQYDVQQGEwJVUzER
  40397. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  40398. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1NiBDZXJ0aWZp
  40399. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM1MTBaFw00MjA4MjMxOTM1MTBaMIGRMQswCQYD
  40400. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  40401. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1
  40402. NiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABH77bOYj
  40403. 43MyCMpg5lOcunSNGLB4kFKA3TjASh3RqMyTpJcGOMoNFWLGjgEqZZ2q3zSRLoHB5DOSMcT9CTqm
  40404. P62jQzBBMA8GA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAwcGADAdBgNVHQ4EFgQUo0EGrJBt
  40405. 0UrrdaVKEJmzsaGLSvcwCgYIKoZIzj0EAwIDRwAwRAIgB+ZU2g6gWrKuEZ+Hxbb/ad4lvvigtwjz
  40406. RM4q3wghDDcCIC0mA6AFvWvR9lz4ZcyGbbOcNEhjhAnFjXca4syc4XR7
  40407. -----END CERTIFICATE-----
  40408. Trustwave Global ECC P384 Certification Authority
  40409. =================================================
  40410. -----BEGIN CERTIFICATE-----
  40411. MIICnTCCAiSgAwIBAgIMCL2Fl2yZJ6SAaEc7MAoGCCqGSM49BAMDMIGRMQswCQYDVQQGEwJVUzER
  40412. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  40413. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4NCBDZXJ0aWZp
  40414. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM2NDNaFw00MjA4MjMxOTM2NDNaMIGRMQswCQYD
  40415. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  40416. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4
  40417. NCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvaDXU1CDFH
  40418. Ba5FmVXxERMuSvgQMSOjfoPTfygIOiYaOs+Xgh+AtycJj9GOMMQKmw6sWASr9zZ9lCOkmwqKi6vr
  40419. /TklZvFe/oyujUF5nQlgziip04pt89ZF1PKYhDhloKNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNV
  40420. HQ8BAf8EBQMDBwYAMB0GA1UdDgQWBBRVqYSJ0sEyvRjLbKYHTsjnnb6CkDAKBggqhkjOPQQDAwNn
  40421. ADBkAjA3AZKXRRJ+oPM+rRk6ct30UJMDEr5E0k9BpIycnR+j9sKS50gU/k6bpZFXrsY3crsCMGcl
  40422. CrEMXu6pY5Jv5ZAL/mYiykf9ijH3g/56vxC+GCsej/YpHpRZ744hN8tRmKVuSw==
  40423. -----END CERTIFICATE-----
  40424. NAVER Global Root Certification Authority
  40425. =========================================
  40426. -----BEGIN CERTIFICATE-----
  40427. MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEMBQAwaTELMAkG
  40428. A1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRGT1JNIENvcnAuMTIwMAYDVQQD
  40429. DClOQVZFUiBHbG9iYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MTgwODU4
  40430. NDJaFw0zNzA4MTgyMzU5NTlaMGkxCzAJBgNVBAYTAktSMSYwJAYDVQQKDB1OQVZFUiBCVVNJTkVT
  40431. UyBQTEFURk9STSBDb3JwLjEyMDAGA1UEAwwpTkFWRVIgR2xvYmFsIFJvb3QgQ2VydGlmaWNhdGlv
  40432. biBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC21PGTXLVAiQqrDZBb
  40433. UGOukJR0F0Vy1ntlWilLp1agS7gvQnXp2XskWjFlqxcX0TM62RHcQDaH38dq6SZeWYp34+hInDEW
  40434. +j6RscrJo+KfziFTowI2MMtSAuXaMl3Dxeb57hHHi8lEHoSTGEq0n+USZGnQJoViAbbJAh2+g1G7
  40435. XNr4rRVqmfeSVPc0W+m/6imBEtRTkZazkVrd/pBzKPswRrXKCAfHcXLJZtM0l/aM9BhK4dA9WkW2
  40436. aacp+yPOiNgSnABIqKYPszuSjXEOdMWLyEz59JuOuDxp7W87UC9Y7cSw0BwbagzivESq2M0UXZR4
  40437. Yb8ObtoqvC8MC3GmsxY/nOb5zJ9TNeIDoKAYv7vxvvTWjIcNQvcGufFt7QSUqP620wbGQGHfnZ3z
  40438. VHbOUzoBppJB7ASjjw2i1QnK1sua8e9DXcCrpUHPXFNwcMmIpi3Ua2FzUCaGYQ5fG8Ir4ozVu53B
  40439. A0K6lNpfqbDKzE0K70dpAy8i+/Eozr9dUGWokG2zdLAIx6yo0es+nPxdGoMuK8u180SdOqcXYZai
  40440. cdNwlhVNt0xz7hlcxVs+Qf6sdWA7G2POAN3aCJBitOUt7kinaxeZVL6HSuOpXgRM6xBtVNbv8ejy
  40441. YhbLgGvtPe31HzClrkvJE+2KAQHJuFFYwGY6sWZLxNUxAmLpdIQM201GLQIDAQABo0IwQDAdBgNV
  40442. HQ4EFgQU0p+I36HNLL3s9TsBAZMzJ7LrYEswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMB
  40443. Af8wDQYJKoZIhvcNAQEMBQADggIBADLKgLOdPVQG3dLSLvCkASELZ0jKbY7gyKoNqo0hV4/GPnrK
  40444. 21HUUrPUloSlWGB/5QuOH/XcChWB5Tu2tyIvCZwTFrFsDDUIbatjcu3cvuzHV+YwIHHW1xDBE1UB
  40445. jCpD5EHxzzp6U5LOogMFDTjfArsQLtk70pt6wKGm+LUx5vR1yblTmXVHIloUFcd4G7ad6Qz4G3bx
  40446. hYTeodoS76TiEJd6eN4MUZeoIUCLhr0N8F5OSza7OyAfikJW4Qsav3vQIkMsRIz75Sq0bBwcupTg
  40447. E34h5prCy8VCZLQelHsIJchxzIdFV4XTnyliIoNRlwAYl3dqmJLJfGBs32x9SuRwTMKeuB330DTH
  40448. D8z7p/8Dvq1wkNoL3chtl1+afwkyQf3NosxabUzyqkn+Zvjp2DXrDige7kgvOtB5CTh8piKCk5XQ
  40449. A76+AqAF3SAi428diDRgxuYKuQl1C/AH6GmWNcf7I4GOODm4RStDeKLRLBT/DShycpWbXgnbiUSY
  40450. qqFJu3FS8r/2/yehNq+4tneI3TqkbZs0kNwUXTC/t+sX5Ie3cdCh13cV1ELX8vMxmV2b3RZtP+oG
  40451. I/hGoiLtk/bdmuYqh7GYVPEi92tF4+KOdh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmg
  40452. kpzNNIaRkPpkUZ3+/uul9XXeifdy
  40453. -----END CERTIFICATE-----
  40454. AC RAIZ FNMT-RCM SERVIDORES SEGUROS
  40455. ===================================
  40456. -----BEGIN CERTIFICATE-----
  40457. MIICbjCCAfOgAwIBAgIQYvYybOXE42hcG2LdnC6dlTAKBggqhkjOPQQDAzB4MQswCQYDVQQGEwJF
  40458. UzERMA8GA1UECgwIRk5NVC1SQ00xDjAMBgNVBAsMBUNlcmVzMRgwFgYDVQRhDA9WQVRFUy1RMjgy
  40459. NjAwNEoxLDAqBgNVBAMMI0FDIFJBSVogRk5NVC1SQ00gU0VSVklET1JFUyBTRUdVUk9TMB4XDTE4
  40460. MTIyMDA5MzczM1oXDTQzMTIyMDA5MzczM1oweDELMAkGA1UEBhMCRVMxETAPBgNVBAoMCEZOTVQt
  40461. UkNNMQ4wDAYDVQQLDAVDZXJlczEYMBYGA1UEYQwPVkFURVMtUTI4MjYwMDRKMSwwKgYDVQQDDCNB
  40462. QyBSQUlaIEZOTVQtUkNNIFNFUlZJRE9SRVMgU0VHVVJPUzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  40463. BPa6V1PIyqvfNkpSIeSX0oNnnvBlUdBeh8dHsVnyV0ebAAKTRBdp20LHsbI6GA60XYyzZl2hNPk2
  40464. LEnb80b8s0RpRBNm/dfF/a82Tc4DTQdxz69qBdKiQ1oKUm8BA06Oi6NCMEAwDwYDVR0TAQH/BAUw
  40465. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFAG5L++/EYZg8k/QQW6rcx/n0m5JMAoGCCqG
  40466. SM49BAMDA2kAMGYCMQCuSuMrQMN0EfKVrRYj3k4MGuZdpSRea0R7/DjiT8ucRRcRTBQnJlU5dUoD
  40467. zBOQn5ICMQD6SmxgiHPz7riYYqnOK8LZiqZwMR2vsJRM60/G49HzYqc8/5MuB1xJAWdpEgJyv+c=
  40468. -----END CERTIFICATE-----
  40469. GlobalSign Root R46
  40470. ===================
  40471. -----BEGIN CERTIFICATE-----
  40472. MIIFWjCCA0KgAwIBAgISEdK7udcjGJ5AXwqdLdDfJWfRMA0GCSqGSIb3DQEBDAUAMEYxCzAJBgNV
  40473. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJv
  40474. b3QgUjQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAX
  40475. BgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBSNDYwggIi
  40476. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCsrHQy6LNl5brtQyYdpokNRbopiLKkHWPd08Es
  40477. CVeJOaFV6Wc0dwxu5FUdUiXSE2te4R2pt32JMl8Nnp8semNgQB+msLZ4j5lUlghYruQGvGIFAha/
  40478. r6gjA7aUD7xubMLL1aa7DOn2wQL7Id5m3RerdELv8HQvJfTqa1VbkNud316HCkD7rRlr+/fKYIje
  40479. 2sGP1q7Vf9Q8g+7XFkyDRTNrJ9CG0Bwta/OrffGFqfUo0q3v84RLHIf8E6M6cqJaESvWJ3En7YEt
  40480. bWaBkoe0G1h6zD8K+kZPTXhc+CtI4wSEy132tGqzZfxCnlEmIyDLPRT5ge1lFgBPGmSXZgjPjHvj
  40481. K8Cd+RTyG/FWaha/LIWFzXg4mutCagI0GIMXTpRW+LaCtfOW3T3zvn8gdz57GSNrLNRyc0NXfeD4
  40482. 12lPFzYE+cCQYDdF3uYM2HSNrpyibXRdQr4G9dlkbgIQrImwTDsHTUB+JMWKmIJ5jqSngiCNI/on
  40483. ccnfxkF0oE32kRbcRoxfKWMxWXEM2G/CtjJ9++ZdU6Z+Ffy7dXxd7Pj2Fxzsx2sZy/N78CsHpdls
  40484. eVR2bJ0cpm4O6XkMqCNqo98bMDGfsVR7/mrLZqrcZdCinkqaByFrgY/bxFn63iLABJzjqls2k+g9
  40485. vXqhnQt2sQvHnf3PmKgGwvgqo6GDoLclcqUC4wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYD
  40486. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA1yrc4GHqMywptWU4jaWSf8FmSwwDQYJKoZIhvcNAQEM
  40487. BQADggIBAHx47PYCLLtbfpIrXTncvtgdokIzTfnvpCo7RGkerNlFo048p9gkUbJUHJNOxO97k4Vg
  40488. JuoJSOD1u8fpaNK7ajFxzHmuEajwmf3lH7wvqMxX63bEIaZHU1VNaL8FpO7XJqti2kM3S+LGteWy
  40489. gxk6x9PbTZ4IevPuzz5i+6zoYMzRx6Fcg0XERczzF2sUyQQCPtIkpnnpHs6i58FZFZ8d4kuaPp92
  40490. CC1r2LpXFNqD6v6MVenQTqnMdzGxRBF6XLE+0xRFFRhiJBPSy03OXIPBNvIQtQ6IbbjhVp+J3pZm
  40491. OUdkLG5NrmJ7v2B0GbhWrJKsFjLtrWhV/pi60zTe9Mlhww6G9kuEYO4Ne7UyWHmRVSyBQ7N0H3qq
  40492. JZ4d16GLuc1CLgSkZoNNiTW2bKg2SnkheCLQQrzRQDGQob4Ez8pn7fXwgNNgyYMqIgXQBztSvwye
  40493. qiv5u+YfjyW6hY0XHgL+XVAEV8/+LbzvXMAaq7afJMbfc2hIkCwU9D9SGuTSyxTDYWnP4vkYxboz
  40494. nxSjBF25cfe1lNj2M8FawTSLfJvdkzrnE6JwYZ+vj+vYxXX4M2bUdGc6N3ec592kD3ZDZopD8p/7
  40495. DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3vouXsXgxT7PntgMTzlSdriVZzH81Xwj3
  40496. QEUxeCp6
  40497. -----END CERTIFICATE-----
  40498. GlobalSign Root E46
  40499. ===================
  40500. -----BEGIN CERTIFICATE-----
  40501. MIICCzCCAZGgAwIBAgISEdK7ujNu1LzmJGjFDYQdmOhDMAoGCCqGSM49BAMDMEYxCzAJBgNVBAYT
  40502. AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJvb3Qg
  40503. RTQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNV
  40504. BAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBFNDYwdjAQBgcq
  40505. hkjOPQIBBgUrgQQAIgNiAAScDrHPt+ieUnd1NPqlRqetMhkytAepJ8qUuwzSChDH2omwlwxwEwkB
  40506. jtjqR+q+soArzfwoDdusvKSGN+1wCAB16pMLey5SnCNoIwZD7JIvU4Tb+0cUB+hflGddyXqBPCCj
  40507. QjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQxCpCPtsad0kRL
  40508. gLWi5h+xEk8blTAKBggqhkjOPQQDAwNoADBlAjEA31SQ7Zvvi5QCkxeCmb6zniz2C5GMn0oUsfZk
  40509. vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+
  40510. CAezNIm8BZ/3Hobui3A=
  40511. -----END CERTIFICATE-----
  40512. GLOBALTRUST 2020
  40513. ================
  40514. -----BEGIN CERTIFICATE-----
  40515. MIIFgjCCA2qgAwIBAgILWku9WvtPilv6ZeUwDQYJKoZIhvcNAQELBQAwTTELMAkGA1UEBhMCQVQx
  40516. IzAhBgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVT
  40517. VCAyMDIwMB4XDTIwMDIxMDAwMDAwMFoXDTQwMDYxMDAwMDAwMFowTTELMAkGA1UEBhMCQVQxIzAh
  40518. BgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVTVCAy
  40519. MDIwMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAri5WrRsc7/aVj6B3GyvTY4+ETUWi
  40520. D59bRatZe1E0+eyLinjF3WuvvcTfk0Uev5E4C64OFudBc/jbu9G4UeDLgztzOG53ig9ZYybNpyrO
  40521. VPu44sB8R85gfD+yc/LAGbaKkoc1DZAoouQVBGM+uq/ufF7MpotQsjj3QWPKzv9pj2gOlTblzLmM
  40522. CcpL3TGQlsjMH/1WljTbjhzqLL6FLmPdqqmV0/0plRPwyJiT2S0WR5ARg6I6IqIoV6Lr/sCMKKCm
  40523. fecqQjuCgGOlYx8ZzHyyZqjC0203b+J+BlHZRYQfEs4kUmSFC0iAToexIiIwquuuvuAC4EDosEKA
  40524. A1GqtH6qRNdDYfOiaxaJSaSjpCuKAsR49GiKweR6NrFvG5Ybd0mN1MkGco/PU+PcF4UgStyYJ9OR
  40525. JitHHmkHr96i5OTUawuzXnzUJIBHKWk7buis/UDr2O1xcSvy6Fgd60GXIsUf1DnQJ4+H4xj04KlG
  40526. DfV0OoIu0G4skaMxXDtG6nsEEFZegB31pWXogvziB4xiRfUg3kZwhqG8k9MedKZssCz3AwyIDMvU
  40527. clOGvGBG85hqwvG/Q/lwIHfKN0F5VVJjjVsSn8VoxIidrPIwq7ejMZdnrY8XD2zHc+0klGvIg5rQ
  40528. mjdJBKuxFshsSUktq6HQjJLyQUp5ISXbY9e2nKd+Qmn7OmMCAwEAAaNjMGEwDwYDVR0TAQH/BAUw
  40529. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFNwuH9FhN3nkq9XVsxJxaD1qaJwiMB8GA1Ud
  40530. IwQYMBaAFNwuH9FhN3nkq9XVsxJxaD1qaJwiMA0GCSqGSIb3DQEBCwUAA4ICAQCR8EICaEDuw2jA
  40531. VC/f7GLDw56KoDEoqoOOpFaWEhCGVrqXctJUMHytGdUdaG/7FELYjQ7ztdGl4wJCXtzoRlgHNQIw
  40532. 4Lx0SsFDKv/bGtCwr2zD/cuz9X9tAy5ZVp0tLTWMstZDFyySCstd6IwPS3BD0IL/qMy/pJTAvoe9
  40533. iuOTe8aPmxadJ2W8esVCgmxcB9CpwYhgROmYhRZf+I/KARDOJcP5YBugxZfD0yyIMaK9MOzQ0MAS
  40534. 8cE54+X1+NZK3TTN+2/BT+MAi1bikvcoskJ3ciNnxz8RFbLEAwW+uxF7Cr+obuf/WEPPm2eggAe2
  40535. HcqtbepBEX4tdJP7wry+UUTF72glJ4DjyKDUEuzZpTcdN3y0kcra1LGWge9oXHYQSa9+pTeAsRxS
  40536. vTOBTI/53WXZFM2KJVj04sWDpQmQ1GwUY7VA3+vA/MRYfg0UFodUJ25W5HCEuGwyEn6CMUO+1918
  40537. oa2u1qsgEu8KwxCMSZY13At1XrFP1U80DhEgB3VDRemjEdqso5nCtnkn4rnvyOL2NSl6dPrFf4IF
  40538. YqYK6miyeUcGbvJXqBUzxvd4Sj1Ce2t+/vdG6tHrju+IaFvowdlxfv1k7/9nR4hYJS8+hge9+6jl
  40539. gqispdNpQ80xiEmEU5LAsTkbOYMBMMTyqfrQA71yN2BWHzZ8vTmR9W0Nv3vXkg==
  40540. -----END CERTIFICATE-----
  40541. ANF Secure Server Root CA
  40542. =========================
  40543. -----BEGIN CERTIFICATE-----
  40544. MIIF7zCCA9egAwIBAgIIDdPjvGz5a7EwDQYJKoZIhvcNAQELBQAwgYQxEjAQBgNVBAUTCUc2MzI4
  40545. NzUxMDELMAkGA1UEBhMCRVMxJzAlBgNVBAoTHkFORiBBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lv
  40546. bjEUMBIGA1UECxMLQU5GIENBIFJhaXoxIjAgBgNVBAMTGUFORiBTZWN1cmUgU2VydmVyIFJvb3Qg
  40547. Q0EwHhcNMTkwOTA0MTAwMDM4WhcNMzkwODMwMTAwMDM4WjCBhDESMBAGA1UEBRMJRzYzMjg3NTEw
  40548. MQswCQYDVQQGEwJFUzEnMCUGA1UEChMeQU5GIEF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uMRQw
  40549. EgYDVQQLEwtBTkYgQ0EgUmFpejEiMCAGA1UEAxMZQU5GIFNlY3VyZSBTZXJ2ZXIgUm9vdCBDQTCC
  40550. AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANvrayvmZFSVgpCjcqQZAZ2cC4Ffc0m6p6zz
  40551. BE57lgvsEeBbphzOG9INgxwruJ4dfkUyYA8H6XdYfp9qyGFOtibBTI3/TO80sh9l2Ll49a2pcbnv
  40552. T1gdpd50IJeh7WhM3pIXS7yr/2WanvtH2Vdy8wmhrnZEE26cLUQ5vPnHO6RYPUG9tMJJo8gN0pcv
  40553. B2VSAKduyK9o7PQUlrZXH1bDOZ8rbeTzPvY1ZNoMHKGESy9LS+IsJJ1tk0DrtSOOMspvRdOoiXse
  40554. zx76W0OLzc2oD2rKDF65nkeP8Nm2CgtYZRczuSPkdxl9y0oukntPLxB3sY0vaJxizOBQ+OyRp1RM
  40555. VwnVdmPF6GUe7m1qzwmd+nxPrWAI/VaZDxUse6mAq4xhj0oHdkLePfTdsiQzW7i1o0TJrH93PB0j
  40556. 7IKppuLIBkwC/qxcmZkLLxCKpvR/1Yd0DVlJRfbwcVw5Kda/SiOL9V8BY9KHcyi1Swr1+KuCLH5z
  40557. JTIdC2MKF4EA/7Z2Xue0sUDKIbvVgFHlSFJnLNJhiQcND85Cd8BEc5xEUKDbEAotlRyBr+Qc5RQe
  40558. 8TZBAQIvfXOn3kLMTOmJDVb3n5HUA8ZsyY/b2BzgQJhdZpmYgG4t/wHFzstGH6wCxkPmrqKEPMVO
  40559. Hj1tyRRM4y5Bu8o5vzY8KhmqQYdOpc5LMnndkEl/AgMBAAGjYzBhMB8GA1UdIwQYMBaAFJxf0Gxj
  40560. o1+TypOYCK2Mh6UsXME3MB0GA1UdDgQWBBScX9BsY6Nfk8qTmAitjIelLFzBNzAOBgNVHQ8BAf8E
  40561. BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEATh65isagmD9uw2nAalxJ
  40562. UqzLK114OMHVVISfk/CHGT0sZonrDUL8zPB1hT+L9IBdeeUXZ701guLyPI59WzbLWoAAKfLOKyzx
  40563. j6ptBZNscsdW699QIyjlRRA96Gejrw5VD5AJYu9LWaL2U/HANeQvwSS9eS9OICI7/RogsKQOLHDt
  40564. dD+4E5UGUcjohybKpFtqFiGS3XNgnhAY3jyB6ugYw3yJ8otQPr0R4hUDqDZ9MwFsSBXXiJCZBMXM
  40565. 5gf0vPSQ7RPi6ovDj6MzD8EpTBNO2hVWcXNyglD2mjN8orGoGjR0ZVzO0eurU+AagNjqOknkJjCb
  40566. 5RyKqKkVMoaZkgoQI1YS4PbOTOK7vtuNknMBZi9iPrJyJ0U27U1W45eZ/zo1PqVUSlJZS2Db7v54
  40567. EX9K3BR5YLZrZAPbFYPhor72I5dQ8AkzNqdxliXzuUJ92zg/LFis6ELhDtjTO0wugumDLmsx2d1H
  40568. hk9tl5EuT+IocTUW0fJz/iUrB0ckYyfI+PbZa/wSMVYIwFNCr5zQM378BvAxRAMU8Vjq8moNqRGy
  40569. g77FGr8H6lnco4g175x2MjxNBiLOFeXdntiP2t7SxDnlF4HPOEfrf4htWRvfn0IUrn7PqLBmZdo3
  40570. r5+qPeoott7VMVgWglvquxl1AnMaykgaIZOQCo6ThKd9OyMYkomgjaw=
  40571. -----END CERTIFICATE-----
  40572. Certum EC-384 CA
  40573. ================
  40574. -----BEGIN CERTIFICATE-----
  40575. MIICZTCCAeugAwIBAgIQeI8nXIESUiClBNAt3bpz9DAKBggqhkjOPQQDAzB0MQswCQYDVQQGEwJQ
  40576. TDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2Vy
  40577. dGlmaWNhdGlvbiBBdXRob3JpdHkxGTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwHhcNMTgwMzI2
  40578. MDcyNDU0WhcNNDMwMzI2MDcyNDU0WjB0MQswCQYDVQQGEwJQTDEhMB8GA1UEChMYQXNzZWNvIERh
  40579. dGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx
  40580. GTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATEKI6rGFtq
  40581. vm5kN2PkzeyrOvfMobgOgknXhimfoZTy42B4mIF4Bk3y7JoOV2CDn7TmFy8as10CW4kjPMIRBSqn
  40582. iBMY81CE1700LCeJVf/OTOffph8oxPBUw7l8t1Ot68KjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  40583. VR0OBBYEFI0GZnQkdjrzife81r1HfS+8EF9LMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNo
  40584. ADBlAjADVS2m5hjEfO/JUG7BJw+ch69u1RsIGL2SKcHvlJF40jocVYli5RsJHrpka/F2tNQCMQC0
  40585. QoSZ/6vnnvuRlydd3LBbMHHOXjgaatkl5+r3YZJW+OraNsKHZZYuciUvf9/DE8k=
  40586. -----END CERTIFICATE-----
  40587. Certum Trusted Root CA
  40588. ======================
  40589. -----BEGIN CERTIFICATE-----
  40590. MIIFwDCCA6igAwIBAgIQHr9ZULjJgDdMBvfrVU+17TANBgkqhkiG9w0BAQ0FADB6MQswCQYDVQQG
  40591. EwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0g
  40592. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0Ew
  40593. HhcNMTgwMzE2MTIxMDEzWhcNNDMwMzE2MTIxMDEzWjB6MQswCQYDVQQGEwJQTDEhMB8GA1UEChMY
  40594. QXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBB
  40595. dXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEB
  40596. AQUAA4ICDwAwggIKAoICAQDRLY67tzbqbTeRn06TpwXkKQMlzhyC93yZn0EGze2jusDbCSzBfN8p
  40597. fktlL5On1AFrAygYo9idBcEq2EXxkd7fO9CAAozPOA/qp1x4EaTByIVcJdPTsuclzxFUl6s1wB52
  40598. HO8AU5853BSlLCIls3Jy/I2z5T4IHhQqNwuIPMqw9MjCoa68wb4pZ1Xi/K1ZXP69VyywkI3C7Te2
  40599. fJmItdUDmj0VDT06qKhF8JVOJVkdzZhpu9PMMsmN74H+rX2Ju7pgE8pllWeg8xn2A1bUatMn4qGt
  40600. g/BKEiJ3HAVz4hlxQsDsdUaakFjgao4rpUYwBI4Zshfjvqm6f1bxJAPXsiEodg42MEx51UGamqi4
  40601. NboMOvJEGyCI98Ul1z3G4z5D3Yf+xOr1Uz5MZf87Sst4WmsXXw3Hw09Omiqi7VdNIuJGmj8PkTQk
  40602. fVXjjJU30xrwCSss0smNtA0Aq2cpKNgB9RkEth2+dv5yXMSFytKAQd8FqKPVhJBPC/PgP5sZ0jeJ
  40603. P/J7UhyM9uH3PAeXjA6iWYEMspA90+NZRu0PqafegGtaqge2Gcu8V/OXIXoMsSt0Puvap2ctTMSY
  40604. njYJdmZm/Bo/6khUHL4wvYBQv3y1zgD2DGHZ5yQD4OMBgQ692IU0iL2yNqh7XAjlRICMb/gv1SHK
  40605. HRzQ+8S1h9E6Tsd2tTVItQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSM+xx1
  40606. vALTn04uSNn5YFSqxLNP+jAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQENBQADggIBAEii1QAL
  40607. LtA/vBzVtVRJHlpr9OTy4EA34MwUe7nJ+jW1dReTagVphZzNTxl4WxmB82M+w85bj/UvXgF2Ez8s
  40608. ALnNllI5SW0ETsXpD4YN4fqzX4IS8TrOZgYkNCvozMrnadyHncI013nR03e4qllY/p0m+jiGPp2K
  40609. h2RX5Rc64vmNueMzeMGQ2Ljdt4NR5MTMI9UGfOZR0800McD2RrsLrfw9EAUqO0qRJe6M1ISHgCq8
  40610. CYyqOhNf6DR5UMEQGfnTKB7U0VEwKbOukGfWHwpjscWpxkIxYxeU72nLL/qMFH3EQxiJ2fAyQOaA
  40611. 4kZf5ePBAFmo+eggvIksDkc0C+pXwlM2/KfUrzHN/gLldfq5Jwn58/U7yn2fqSLLiMmq0Uc9Nneo
  40612. WWRrJ8/vJ8HjJLWG965+Mk2weWjROeiQWMODvA8s1pfrzgzhIMfatz7DP78v3DSk+yshzWePS/Tj
  40613. 6tQ/50+6uaWTRRxmHyH6ZF5v4HaUMst19W7l9o/HuKTMqJZ9ZPskWkoDbGs4xugDQ5r3V7mzKWmT
  40614. OPQD8rv7gmsHINFSH5pkAnuYZttcTVoP0ISVoDwUQwbKytu4QTbaakRnh6+v40URFWkIsr4WOZck
  40615. bxJF0WddCajJFdr60qZfE2Efv4WstK2tBZQIgx51F9NxO5NQI1mg7TyRVJ12AMXDuDjb
  40616. -----END CERTIFICATE-----
  40617. TunTrust Root CA
  40618. ================
  40619. -----BEGIN CERTIFICATE-----
  40620. MIIFszCCA5ugAwIBAgIUEwLV4kBMkkaGFmddtLu7sms+/BMwDQYJKoZIhvcNAQELBQAwYTELMAkG
  40621. A1UEBhMCVE4xNzA1BgNVBAoMLkFnZW5jZSBOYXRpb25hbGUgZGUgQ2VydGlmaWNhdGlvbiBFbGVj
  40622. dHJvbmlxdWUxGTAXBgNVBAMMEFR1blRydXN0IFJvb3QgQ0EwHhcNMTkwNDI2MDg1NzU2WhcNNDQw
  40623. NDI2MDg1NzU2WjBhMQswCQYDVQQGEwJUTjE3MDUGA1UECgwuQWdlbmNlIE5hdGlvbmFsZSBkZSBD
  40624. ZXJ0aWZpY2F0aW9uIEVsZWN0cm9uaXF1ZTEZMBcGA1UEAwwQVHVuVHJ1c3QgUm9vdCBDQTCCAiIw
  40625. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMPN0/y9BFPdDCA61YguBUtB9YOCfvdZn56eY+hz
  40626. 2vYGqU8ftPkLHzmMmiDQfgbU7DTZhrx1W4eI8NLZ1KMKsmwb60ksPqxd2JQDoOw05TDENX37Jk0b
  40627. bjBU2PWARZw5rZzJJQRNmpA+TkBuimvNKWfGzC3gdOgFVwpIUPp6Q9p+7FuaDmJ2/uqdHYVy7BG7
  40628. NegfJ7/Boce7SBbdVtfMTqDhuazb1YMZGoXRlJfXyqNlC/M4+QKu3fZnz8k/9YosRxqZbwUN/dAd
  40629. gjH8KcwAWJeRTIAAHDOFli/LQcKLEITDCSSJH7UP2dl3RxiSlGBcx5kDPP73lad9UKGAwqmDrViW
  40630. VSHbhlnUr8a83YFuB9tgYv7sEG7aaAH0gxupPqJbI9dkxt/con3YS7qC0lH4Zr8GRuR5KiY2eY8f
  40631. Tpkdso8MDhz/yV3A/ZAQprE38806JG60hZC/gLkMjNWb1sjxVj8agIl6qeIbMlEsPvLfe/ZdeikZ
  40632. juXIvTZxi11Mwh0/rViizz1wTaZQmCXcI/m4WEEIcb9PuISgjwBUFfyRbVinljvrS5YnzWuioYas
  40633. DXxU5mZMZl+QviGaAkYt5IPCgLnPSz7ofzwB7I9ezX/SKEIBlYrilz0QIX32nRzFNKHsLA4KUiwS
  40634. VXAkPcvCFDVDXSdOvsC9qnyW5/yeYa1E0wCXAgMBAAGjYzBhMB0GA1UdDgQWBBQGmpsfU33x9aTI
  40635. 04Y+oXNZtPdEITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFAaamx9TffH1pMjThj6hc1m0
  40636. 90QhMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAqgVutt0Vyb+zxiD2BkewhpMl
  40637. 0425yAA/l/VSJ4hxyXT968pk21vvHl26v9Hr7lxpuhbI87mP0zYuQEkHDVneixCwSQXi/5E/S7fd
  40638. Ao74gShczNxtr18UnH1YeA32gAm56Q6XKRm4t+v4FstVEuTGfbvE7Pi1HE4+Z7/FXxttbUcoqgRY
  40639. YdZ2vyJ/0Adqp2RT8JeNnYA/u8EH22Wv5psymsNUk8QcCMNE+3tjEUPRahphanltkE8pjkcFwRJp
  40640. adbGNjHh/PqAulxPxOu3Mqz4dWEX1xAZufHSCe96Qp1bWgvUxpVOKs7/B9dPfhgGiPEZtdmYu65x
  40641. xBzndFlY7wyJz4sfdZMaBBSSSFCp61cpABbjNhzI+L/wM9VBD8TMPN3pM0MBkRArHtG5Xc0yGYuP
  40642. jCB31yLEQtyEFpslbei0VXF/sHyz03FJuc9SpAQ/3D2gu68zngowYI7bnV2UqL1g52KAdoGDDIzM
  40643. MEZJ4gzSqK/rYXHv5yJiqfdcZGyfFoxnNidF9Ql7v/YQCvGwjVRDjAS6oz/v4jXH+XTgbzRB0L9z
  40644. ZVcg+ZtnemZoJE6AZb0QmQZZ8mWvuMZHu/2QeItBcy6vVR/cO5JyboTT0GFMDcx2V+IthSIVNg3r
  40645. AZ3r2OvEhJn7wAzMMujjd9qDRIueVSjAi1jTkD5OGwDxFa2DK5o=
  40646. -----END CERTIFICATE-----
  40647. HARICA TLS RSA Root CA 2021
  40648. ===========================
  40649. -----BEGIN CERTIFICATE-----
  40650. MIIFpDCCA4ygAwIBAgIQOcqTHO9D88aOk8f0ZIk4fjANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQG
  40651. EwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  40652. cyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBSU0EgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTEwNTUz
  40653. OFoXDTQ1MDIxMzEwNTUzN1owbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRl
  40654. bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgUlNB
  40655. IFJvb3QgQ0EgMjAyMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIvC569lmwVnlskN
  40656. JLnQDmT8zuIkGCyEf3dRywQRNrhe7Wlxp57kJQmXZ8FHws+RFjZiPTgE4VGC/6zStGndLuwRo0Xu
  40657. a2s7TL+MjaQenRG56Tj5eg4MmOIjHdFOY9TnuEFE+2uva9of08WRiFukiZLRgeaMOVig1mlDqa2Y
  40658. Ulhu2wr7a89o+uOkXjpFc5gH6l8Cct4MpbOfrqkdtx2z/IpZ525yZa31MJQjB/OCFks1mJxTuy/K
  40659. 5FrZx40d/JiZ+yykgmvwKh+OC19xXFyuQnspiYHLA6OZyoieC0AJQTPb5lh6/a6ZcMBaD9YThnEv
  40660. dmn8kN3bLW7R8pv1GmuebxWMevBLKKAiOIAkbDakO/IwkfN4E8/BPzWr8R0RI7VDIp4BkrcYAuUR
  40661. 0YLbFQDMYTfBKnya4dC6s1BG7oKsnTH4+yPiAwBIcKMJJnkVU2DzOFytOOqBAGMUuTNe3QvboEUH
  40662. GjMJ+E20pwKmafTCWQWIZYVWrkvL4N48fS0ayOn7H6NhStYqE613TBoYm5EPWNgGVMWX+Ko/IIqm
  40663. haZ39qb8HOLubpQzKoNQhArlT4b4UEV4AIHrW2jjJo3Me1xR9BQsQL4aYB16cmEdH2MtiKrOokWQ
  40664. CPxrvrNQKlr9qEgYRtaQQJKQCoReaDH46+0N0x3GfZkYVVYnZS6NRcUk7M7jAgMBAAGjQjBAMA8G
  40665. A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFApII6ZgpJIKM+qTW8VX6iVNvRLuMA4GA1UdDwEB/wQE
  40666. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAPpBIqm5iFSVmewzVjIuJndftTgfvnNAUX15QvWiWkKQU
  40667. EapobQk1OUAJ2vQJLDSle1mESSmXdMgHHkdt8s4cUCbjnj1AUz/3f5Z2EMVGpdAgS1D0NTsY9FVq
  40668. QRtHBmg8uwkIYtlfVUKqrFOFrJVWNlar5AWMxajaH6NpvVMPxP/cyuN+8kyIhkdGGvMA9YCRotxD
  40669. QpSbIPDRzbLrLFPCU3hKTwSUQZqPJzLB5UkZv/HywouoCjkxKLR9YjYsTewfM7Z+d21+UPCfDtcR
  40670. j88YxeMn/ibvBZ3PzzfF0HvaO7AWhAw6k9a+F9sPPg4ZeAnHqQJyIkv3N3a6dcSFA1pj1bF1BcK5
  40671. vZStjBWZp5N99sXzqnTPBIWUmAD04vnKJGW/4GKvyMX6ssmeVkjaef2WdhW+o45WxLM0/L5H9MG0
  40672. qPzVMIho7suuyWPEdr6sOBjhXlzPrjoiUevRi7PzKzMHVIf6tLITe7pTBGIBnfHAT+7hOtSLIBD6
  40673. Alfm78ELt5BGnBkpjNxvoEppaZS3JGWg/6w/zgH7IS79aPib8qXPMThcFarmlwDB31qlpzmq6YR/
  40674. PFGoOtmUW4y/Twhx5duoXNTSpv4Ao8YWxw/ogM4cKGR0GQjTQuPOAF1/sdwTsOEFy9EgqoZ0njnn
  40675. kf3/W9b3raYvAwtt41dU63ZTGI0RmLo=
  40676. -----END CERTIFICATE-----
  40677. HARICA TLS ECC Root CA 2021
  40678. ===========================
  40679. -----BEGIN CERTIFICATE-----
  40680. MIICVDCCAdugAwIBAgIQZ3SdjXfYO2rbIvT/WeK/zjAKBggqhkjOPQQDAzBsMQswCQYDVQQGEwJH
  40681. UjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBD
  40682. QTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBFQ0MgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTExMDExMFoX
  40683. DTQ1MDIxMzExMDEwOVowbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWlj
  40684. IGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgRUNDIFJv
  40685. b3QgQ0EgMjAyMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDgI/rGgltJ6rK9JOtDA4MM7KKrxcm1l
  40686. AEeIhPyaJmuqS7psBAqIXhfyVYf8MLA04jRYVxqEU+kw2anylnTDUR9YSTHMmE5gEYd103KUkE+b
  40687. ECUqqHgtvpBBWJAVcqeht6NCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUyRtTgRL+BNUW
  40688. 0aq8mm+3oJUZbsowDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2cAMGQCMBHervjcToiwqfAi
  40689. rcJRQO9gcS3ujwLEXQNwSaSS6sUUiHCm0w2wqsosQJz76YJumgIwK0eaB8bRwoF8yguWGEEbo/Qw
  40690. CZ61IygNnxS2PFOiTAZpffpskcYqSUXm7LcT4Tps
  40691. -----END CERTIFICATE-----
  40692. <?php
  40693. namespace Composer\CaBundle;
  40694. use Psr\Log\LoggerInterface;
  40695. use Symfony\Component\Process\PhpProcess;
  40696. class CaBundle
  40697. {
  40698. private static $caPath;
  40699. private static $caFileValidity = array();
  40700. private static $useOpensslParse;
  40701. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  40702. {
  40703. if (self::$caPath !== null) {
  40704. return self::$caPath;
  40705. }
  40706. $caBundlePaths = array();
  40707. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  40708. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  40709. $caBundlePaths[] = ini_get('openssl.cafile');
  40710. $caBundlePaths[] = ini_get('openssl.capath');
  40711. $otherLocations = array(
  40712. '/etc/pki/tls/certs/ca-bundle.crt',
  40713. '/etc/ssl/certs/ca-certificates.crt',
  40714. '/etc/ssl/ca-bundle.pem',
  40715. '/usr/local/share/certs/ca-root-nss.crt',
  40716. '/usr/ssl/certs/ca-bundle.crt',
  40717. '/opt/local/share/curl/curl-ca-bundle.crt',
  40718. '/usr/local/share/curl/curl-ca-bundle.crt',
  40719. '/usr/share/ssl/certs/ca-bundle.crt',
  40720. '/etc/ssl/cert.pem',
  40721. '/usr/local/etc/ssl/cert.pem',
  40722. '/usr/local/etc/openssl/cert.pem',
  40723. '/usr/local/etc/openssl@1.1/cert.pem',
  40724. );
  40725. foreach($otherLocations as $location) {
  40726. $otherLocations[] = dirname($location);
  40727. }
  40728. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  40729. foreach ($caBundlePaths as $caBundle) {
  40730. if ($caBundle && self::caFileUsable($caBundle, $logger)) {
  40731. return self::$caPath = $caBundle;
  40732. }
  40733. if ($caBundle && self::caDirUsable($caBundle, $logger)) {
  40734. return self::$caPath = $caBundle;
  40735. }
  40736. }
  40737. return self::$caPath = static::getBundledCaBundlePath();
  40738. }
  40739. public static function getBundledCaBundlePath()
  40740. {
  40741. $caBundleFile = __DIR__.'/../res/cacert.pem';
  40742. if (0 === strpos($caBundleFile, 'phar://')) {
  40743. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-');
  40744. if (false === $tempCaBundleFile) {
  40745. throw new \RuntimeException('Could not create a temporary file to store the bundled CA file');
  40746. }
  40747. file_put_contents(
  40748. $tempCaBundleFile,
  40749. file_get_contents($caBundleFile)
  40750. );
  40751. register_shutdown_function(function() use ($tempCaBundleFile) {
  40752. @unlink($tempCaBundleFile);
  40753. });
  40754. $caBundleFile = $tempCaBundleFile;
  40755. }
  40756. return $caBundleFile;
  40757. }
  40758. public static function validateCaFile($filename, LoggerInterface $logger = null)
  40759. {
  40760. static $warned = false;
  40761. if (isset(self::$caFileValidity[$filename])) {
  40762. return self::$caFileValidity[$filename];
  40763. }
  40764. $contents = file_get_contents($filename);
  40765. if (!static::isOpensslParseSafe()) {
  40766. if (!$warned && $logger) {
  40767. $logger->warning(sprintf(
  40768. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  40769. PHP_VERSION
  40770. ));
  40771. $warned = true;
  40772. }
  40773. $isValid = !empty($contents);
  40774. } elseif (is_string($contents) && strlen($contents) > 0) {
  40775. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  40776. if (null === $contents) {
  40777. $isValid = false;
  40778. } else {
  40779. $isValid = (bool) openssl_x509_parse($contents);
  40780. }
  40781. } else {
  40782. $isValid = false;
  40783. }
  40784. if ($logger) {
  40785. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  40786. }
  40787. return self::$caFileValidity[$filename] = $isValid;
  40788. }
  40789. public static function isOpensslParseSafe()
  40790. {
  40791. if (null !== self::$useOpensslParse) {
  40792. return self::$useOpensslParse;
  40793. }
  40794. if (PHP_VERSION_ID >= 50600) {
  40795. return self::$useOpensslParse = true;
  40796. }
  40797. if (
  40798. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  40799. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  40800. || PHP_VERSION_ID >= 50507
  40801. ) {
  40802. return self::$useOpensslParse = true;
  40803. }
  40804. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  40805. return self::$useOpensslParse = false;
  40806. }
  40807. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  40808. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  40809. if (preg_match($regex, PHP_VERSION, $m)) {
  40810. return ((int) $m[1]) >= $fixedVersion;
  40811. }
  40812. return false;
  40813. };
  40814. if (
  40815. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  40816. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  40817. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  40818. ) {
  40819. return self::$useOpensslParse = true;
  40820. }
  40821. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  40822. return self::$useOpensslParse = false;
  40823. }
  40824. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  40825. $script = <<<'EOT'
  40826. error_reporting(-1);
  40827. $info = openssl_x509_parse(base64_decode('%s'));
  40828. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  40829. EOT;
  40830. $script = '<'."?php\n".sprintf($script, $cert);
  40831. try {
  40832. $process = new PhpProcess($script);
  40833. $process->mustRun();
  40834. } catch (\Exception $e) {
  40835. return self::$useOpensslParse = false;
  40836. }
  40837. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  40838. $errorOutput = trim($process->getErrorOutput());
  40839. if (
  40840. is_array($output)
  40841. && count($output) === 3
  40842. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  40843. && $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
  40844. && $output[2] === 'int(-1)'
  40845. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  40846. ) {
  40847. return self::$useOpensslParse = true;
  40848. }
  40849. return self::$useOpensslParse = false;
  40850. }
  40851. public static function reset()
  40852. {
  40853. self::$caFileValidity = array();
  40854. self::$caPath = null;
  40855. self::$useOpensslParse = null;
  40856. }
  40857. private static function getEnvVariable($name)
  40858. {
  40859. if (isset($_SERVER[$name])) {
  40860. return (string) $_SERVER[$name];
  40861. }
  40862. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  40863. return (string) $value;
  40864. }
  40865. return false;
  40866. }
  40867. private static function caFileUsable($certFile, LoggerInterface $logger = null)
  40868. {
  40869. return $certFile
  40870. && static::isFile($certFile, $logger)
  40871. && static::isReadable($certFile, $logger)
  40872. && static::validateCaFile($certFile, $logger);
  40873. }
  40874. private static function caDirUsable($certDir, LoggerInterface $logger = null)
  40875. {
  40876. return $certDir
  40877. && static::isDir($certDir, $logger)
  40878. && static::isReadable($certDir, $logger)
  40879. && static::glob($certDir . '/*', $logger);
  40880. }
  40881. private static function isFile($certFile, LoggerInterface $logger = null)
  40882. {
  40883. $isFile = @is_file($certFile);
  40884. if (!$isFile && $logger) {
  40885. $logger->debug(sprintf('Checked CA file %s does not exist or it is not a file.', $certFile));
  40886. }
  40887. return $isFile;
  40888. }
  40889. private static function isDir($certDir, LoggerInterface $logger = null)
  40890. {
  40891. $isDir = @is_dir($certDir);
  40892. if (!$isDir && $logger) {
  40893. $logger->debug(sprintf('Checked directory %s does not exist or it is not a directory.', $certDir));
  40894. }
  40895. return $isDir;
  40896. }
  40897. private static function isReadable($certFileOrDir, LoggerInterface $logger = null)
  40898. {
  40899. $isReadable = @is_readable($certFileOrDir);
  40900. if (!$isReadable && $logger) {
  40901. $logger->debug(sprintf('Checked file or directory %s is not readable.', $certFileOrDir));
  40902. }
  40903. return $isReadable;
  40904. }
  40905. private static function glob($pattern, LoggerInterface $logger = null)
  40906. {
  40907. $certs = glob($pattern);
  40908. if ($certs === false) {
  40909. if ($logger) {
  40910. $logger->debug(sprintf("An error occurred while trying to find certificates for pattern: %s", $pattern));
  40911. }
  40912. return false;
  40913. }
  40914. if (count($certs) === 0) {
  40915. if ($logger) {
  40916. $logger->debug(sprintf("No CA files found for pattern: %s", $pattern));
  40917. }
  40918. return false;
  40919. }
  40920. return true;
  40921. }
  40922. }
  40923. <?php return array(
  40924. 'root' => array(
  40925. 'pretty_version' => '2.1.14',
  40926. 'version' => '2.1.14.0',
  40927. 'type' => 'library',
  40928. 'install_path' => __DIR__ . '/../../',
  40929. 'aliases' => array(),
  40930. 'reference' => 'cd28fc05b0c9d3beaf58b57018725c4dc15a6446',
  40931. 'name' => 'composer/composer',
  40932. 'dev' => false,
  40933. ),
  40934. 'versions' => array(
  40935. 'composer/ca-bundle' => array(
  40936. 'pretty_version' => '1.3.1',
  40937. 'version' => '1.3.1.0',
  40938. 'type' => 'library',
  40939. 'install_path' => __DIR__ . '/./ca-bundle',
  40940. 'aliases' => array(),
  40941. 'reference' => '4c679186f2aca4ab6a0f1b0b9cf9252decb44d0b',
  40942. 'dev_requirement' => false,
  40943. ),
  40944. 'composer/composer' => array(
  40945. 'pretty_version' => '2.1.14',
  40946. 'version' => '2.1.14.0',
  40947. 'type' => 'library',
  40948. 'install_path' => __DIR__ . '/../../',
  40949. 'aliases' => array(),
  40950. 'reference' => 'cd28fc05b0c9d3beaf58b57018725c4dc15a6446',
  40951. 'dev_requirement' => false,
  40952. ),
  40953. 'composer/metadata-minifier' => array(
  40954. 'pretty_version' => '1.0.0',
  40955. 'version' => '1.0.0.0',
  40956. 'type' => 'library',
  40957. 'install_path' => __DIR__ . '/./metadata-minifier',
  40958. 'aliases' => array(),
  40959. 'reference' => 'c549d23829536f0d0e984aaabbf02af91f443207',
  40960. 'dev_requirement' => false,
  40961. ),
  40962. 'composer/semver' => array(
  40963. 'pretty_version' => '3.2.6',
  40964. 'version' => '3.2.6.0',
  40965. 'type' => 'library',
  40966. 'install_path' => __DIR__ . '/./semver',
  40967. 'aliases' => array(),
  40968. 'reference' => '83e511e247de329283478496f7a1e114c9517506',
  40969. 'dev_requirement' => false,
  40970. ),
  40971. 'composer/spdx-licenses' => array(
  40972. 'pretty_version' => '1.5.6',
  40973. 'version' => '1.5.6.0',
  40974. 'type' => 'library',
  40975. 'install_path' => __DIR__ . '/./spdx-licenses',
  40976. 'aliases' => array(),
  40977. 'reference' => 'a30d487169d799745ca7280bc90fdfa693536901',
  40978. 'dev_requirement' => false,
  40979. ),
  40980. 'composer/xdebug-handler' => array(
  40981. 'pretty_version' => '2.0.2',
  40982. 'version' => '2.0.2.0',
  40983. 'type' => 'library',
  40984. 'install_path' => __DIR__ . '/./xdebug-handler',
  40985. 'aliases' => array(),
  40986. 'reference' => '84674dd3a7575ba617f5a76d7e9e29a7d3891339',
  40987. 'dev_requirement' => false,
  40988. ),
  40989. 'justinrainbow/json-schema' => array(
  40990. 'pretty_version' => '5.2.11',
  40991. 'version' => '5.2.11.0',
  40992. 'type' => 'library',
  40993. 'install_path' => __DIR__ . '/../justinrainbow/json-schema',
  40994. 'aliases' => array(),
  40995. 'reference' => '2ab6744b7296ded80f8cc4f9509abbff393399aa',
  40996. 'dev_requirement' => false,
  40997. ),
  40998. 'psr/log' => array(
  40999. 'pretty_version' => '1.1.4',
  41000. 'version' => '1.1.4.0',
  41001. 'type' => 'library',
  41002. 'install_path' => __DIR__ . '/../psr/log',
  41003. 'aliases' => array(),
  41004. 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
  41005. 'dev_requirement' => false,
  41006. ),
  41007. 'react/promise' => array(
  41008. 'pretty_version' => 'v1.2.1',
  41009. 'version' => '1.2.1.0',
  41010. 'type' => 'library',
  41011. 'install_path' => __DIR__ . '/../react/promise',
  41012. 'aliases' => array(),
  41013. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  41014. 'dev_requirement' => false,
  41015. ),
  41016. 'seld/jsonlint' => array(
  41017. 'pretty_version' => '1.8.3',
  41018. 'version' => '1.8.3.0',
  41019. 'type' => 'library',
  41020. 'install_path' => __DIR__ . '/../seld/jsonlint',
  41021. 'aliases' => array(),
  41022. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  41023. 'dev_requirement' => false,
  41024. ),
  41025. 'seld/phar-utils' => array(
  41026. 'pretty_version' => '1.1.2',
  41027. 'version' => '1.1.2.0',
  41028. 'type' => 'library',
  41029. 'install_path' => __DIR__ . '/../seld/phar-utils',
  41030. 'aliases' => array(),
  41031. 'reference' => '749042a2315705d2dfbbc59234dd9ceb22bf3ff0',
  41032. 'dev_requirement' => false,
  41033. ),
  41034. 'symfony/console' => array(
  41035. 'pretty_version' => 'v2.8.52',
  41036. 'version' => '2.8.52.0',
  41037. 'type' => 'library',
  41038. 'install_path' => __DIR__ . '/../symfony/console',
  41039. 'aliases' => array(),
  41040. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  41041. 'dev_requirement' => false,
  41042. ),
  41043. 'symfony/debug' => array(
  41044. 'pretty_version' => 'v2.8.52',
  41045. 'version' => '2.8.52.0',
  41046. 'type' => 'library',
  41047. 'install_path' => __DIR__ . '/../symfony/debug',
  41048. 'aliases' => array(),
  41049. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  41050. 'dev_requirement' => false,
  41051. ),
  41052. 'symfony/filesystem' => array(
  41053. 'pretty_version' => 'v2.8.52',
  41054. 'version' => '2.8.52.0',
  41055. 'type' => 'library',
  41056. 'install_path' => __DIR__ . '/../symfony/filesystem',
  41057. 'aliases' => array(),
  41058. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  41059. 'dev_requirement' => false,
  41060. ),
  41061. 'symfony/finder' => array(
  41062. 'pretty_version' => 'v2.8.52',
  41063. 'version' => '2.8.52.0',
  41064. 'type' => 'library',
  41065. 'install_path' => __DIR__ . '/../symfony/finder',
  41066. 'aliases' => array(),
  41067. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  41068. 'dev_requirement' => false,
  41069. ),
  41070. 'symfony/polyfill-ctype' => array(
  41071. 'pretty_version' => 'v1.19.0',
  41072. 'version' => '1.19.0.0',
  41073. 'type' => 'library',
  41074. 'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
  41075. 'aliases' => array(),
  41076. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  41077. 'dev_requirement' => false,
  41078. ),
  41079. 'symfony/polyfill-mbstring' => array(
  41080. 'pretty_version' => 'v1.19.0',
  41081. 'version' => '1.19.0.0',
  41082. 'type' => 'library',
  41083. 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
  41084. 'aliases' => array(),
  41085. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  41086. 'dev_requirement' => false,
  41087. ),
  41088. 'symfony/process' => array(
  41089. 'pretty_version' => 'v2.8.52',
  41090. 'version' => '2.8.52.0',
  41091. 'type' => 'library',
  41092. 'install_path' => __DIR__ . '/../symfony/process',
  41093. 'aliases' => array(),
  41094. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  41095. 'dev_requirement' => false,
  41096. ),
  41097. ),
  41098. );
  41099. Copyright (C) 2021 Composer
  41100. Permission is hereby granted, free of charge, to any person obtaining a copy of
  41101. this software and associated documentation files (the "Software"), to deal in
  41102. the Software without restriction, including without limitation the rights to
  41103. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  41104. of the Software, and to permit persons to whom the Software is furnished to do
  41105. so, subject to the following conditions:
  41106. The above copyright notice and this permission notice shall be included in all
  41107. copies or substantial portions of the Software.
  41108. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  41109. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  41110. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41111. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  41112. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  41113. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  41114. SOFTWARE.
  41115. <?php
  41116. namespace Composer\MetadataMinifier;
  41117. class MetadataMinifier
  41118. {
  41119. public static function expand(array $versions)
  41120. {
  41121. $expanded = array();
  41122. $expandedVersion = null;
  41123. foreach ($versions as $versionData) {
  41124. if (!$expandedVersion) {
  41125. $expandedVersion = $versionData;
  41126. $expanded[] = $expandedVersion;
  41127. continue;
  41128. }
  41129. foreach ($versionData as $key => $val) {
  41130. if ($val === '__unset') {
  41131. unset($expandedVersion[$key]);
  41132. } else {
  41133. $expandedVersion[$key] = $val;
  41134. }
  41135. }
  41136. $expanded[] = $expandedVersion;
  41137. }
  41138. return $expanded;
  41139. }
  41140. public static function minify(array $versions)
  41141. {
  41142. $minifiedVersions = array();
  41143. $lastKnownVersionData = null;
  41144. foreach ($versions as $version) {
  41145. if (!$lastKnownVersionData) {
  41146. $lastKnownVersionData = $version;
  41147. $minifiedVersions[] = $version;
  41148. continue;
  41149. }
  41150. $minifiedVersion = array();
  41151. foreach ($version as $key => $val) {
  41152. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  41153. $minifiedVersion[$key] = $val;
  41154. $lastKnownVersionData[$key] = $val;
  41155. }
  41156. }
  41157. foreach ($lastKnownVersionData as $key => $val) {
  41158. if (!isset($version[$key])) {
  41159. $minifiedVersion[$key] = "__unset";
  41160. unset($lastKnownVersionData[$key]);
  41161. }
  41162. }
  41163. $minifiedVersions[] = $minifiedVersion;
  41164. }
  41165. return $minifiedVersions;
  41166. }
  41167. }
  41168. Copyright (C) 2015 Composer
  41169. Permission is hereby granted, free of charge, to any person obtaining a copy of
  41170. this software and associated documentation files (the "Software"), to deal in
  41171. the Software without restriction, including without limitation the rights to
  41172. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  41173. of the Software, and to permit persons to whom the Software is furnished to do
  41174. so, subject to the following conditions:
  41175. The above copyright notice and this permission notice shall be included in all
  41176. copies or substantial portions of the Software.
  41177. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  41178. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  41179. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41180. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  41181. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  41182. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  41183. SOFTWARE.
  41184. <?php
  41185. namespace Composer\Semver;
  41186. use Composer\Semver\Constraint\Constraint;
  41187. class Comparator
  41188. {
  41189. public static function greaterThan($version1, $version2)
  41190. {
  41191. return self::compare($version1, '>', $version2);
  41192. }
  41193. public static function greaterThanOrEqualTo($version1, $version2)
  41194. {
  41195. return self::compare($version1, '>=', $version2);
  41196. }
  41197. public static function lessThan($version1, $version2)
  41198. {
  41199. return self::compare($version1, '<', $version2);
  41200. }
  41201. public static function lessThanOrEqualTo($version1, $version2)
  41202. {
  41203. return self::compare($version1, '<=', $version2);
  41204. }
  41205. public static function equalTo($version1, $version2)
  41206. {
  41207. return self::compare($version1, '==', $version2);
  41208. }
  41209. public static function notEqualTo($version1, $version2)
  41210. {
  41211. return self::compare($version1, '!=', $version2);
  41212. }
  41213. public static function compare($version1, $operator, $version2)
  41214. {
  41215. $constraint = new Constraint($operator, $version2);
  41216. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  41217. }
  41218. }
  41219. <?php
  41220. namespace Composer\Semver;
  41221. use Composer\Semver\Constraint\Constraint;
  41222. use Composer\Semver\Constraint\ConstraintInterface;
  41223. class CompilingMatcher
  41224. {
  41225. private static $compiledCheckerCache = array();
  41226. private static $enabled;
  41227. private static $transOpInt = array(
  41228. Constraint::OP_EQ => Constraint::STR_OP_EQ,
  41229. Constraint::OP_LT => Constraint::STR_OP_LT,
  41230. Constraint::OP_LE => Constraint::STR_OP_LE,
  41231. Constraint::OP_GT => Constraint::STR_OP_GT,
  41232. Constraint::OP_GE => Constraint::STR_OP_GE,
  41233. Constraint::OP_NE => Constraint::STR_OP_NE,
  41234. );
  41235. public static function match(ConstraintInterface $constraint, $operator, $version)
  41236. {
  41237. if (self::$enabled === null) {
  41238. self::$enabled = !\in_array('eval', explode(',', (string) ini_get('disable_functions')), true);
  41239. }
  41240. if (!self::$enabled) {
  41241. return $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  41242. }
  41243. $cacheKey = $operator.$constraint;
  41244. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  41245. $code = $constraint->compile($operator);
  41246. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  41247. } else {
  41248. $function = self::$compiledCheckerCache[$cacheKey];
  41249. }
  41250. return $function($version, strpos($version, 'dev-') === 0);
  41251. }
  41252. }
  41253. <?php
  41254. namespace Composer\Semver\Constraint;
  41255. class Bound
  41256. {
  41257. private $version;
  41258. private $isInclusive;
  41259. public function __construct($version, $isInclusive)
  41260. {
  41261. $this->version = $version;
  41262. $this->isInclusive = $isInclusive;
  41263. }
  41264. public function getVersion()
  41265. {
  41266. return $this->version;
  41267. }
  41268. public function isInclusive()
  41269. {
  41270. return $this->isInclusive;
  41271. }
  41272. public function isZero()
  41273. {
  41274. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  41275. }
  41276. public function isPositiveInfinity()
  41277. {
  41278. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  41279. }
  41280. public function compareTo(Bound $other, $operator)
  41281. {
  41282. if (!\in_array($operator, array('<', '>'), true)) {
  41283. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  41284. }
  41285. if ($this == $other) {
  41286. return false;
  41287. }
  41288. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  41289. if (0 !== $compareResult) {
  41290. return (('>' === $operator) ? 1 : -1) === $compareResult;
  41291. }
  41292. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  41293. }
  41294. public function __toString()
  41295. {
  41296. return sprintf(
  41297. '%s [%s]',
  41298. $this->getVersion(),
  41299. $this->isInclusive() ? 'inclusive' : 'exclusive'
  41300. );
  41301. }
  41302. public static function zero()
  41303. {
  41304. return new Bound('0.0.0.0-dev', true);
  41305. }
  41306. public static function positiveInfinity()
  41307. {
  41308. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  41309. }
  41310. }
  41311. <?php
  41312. namespace Composer\Semver\Constraint;
  41313. class Constraint implements ConstraintInterface
  41314. {
  41315. const OP_EQ = 0;
  41316. const OP_LT = 1;
  41317. const OP_LE = 2;
  41318. const OP_GT = 3;
  41319. const OP_GE = 4;
  41320. const OP_NE = 5;
  41321. const STR_OP_EQ = '==';
  41322. const STR_OP_EQ_ALT = '=';
  41323. const STR_OP_LT = '<';
  41324. const STR_OP_LE = '<=';
  41325. const STR_OP_GT = '>';
  41326. const STR_OP_GE = '>=';
  41327. const STR_OP_NE = '!=';
  41328. const STR_OP_NE_ALT = '<>';
  41329. private static $transOpStr = array(
  41330. '=' => self::OP_EQ,
  41331. '==' => self::OP_EQ,
  41332. '<' => self::OP_LT,
  41333. '<=' => self::OP_LE,
  41334. '>' => self::OP_GT,
  41335. '>=' => self::OP_GE,
  41336. '<>' => self::OP_NE,
  41337. '!=' => self::OP_NE,
  41338. );
  41339. private static $transOpInt = array(
  41340. self::OP_EQ => '==',
  41341. self::OP_LT => '<',
  41342. self::OP_LE => '<=',
  41343. self::OP_GT => '>',
  41344. self::OP_GE => '>=',
  41345. self::OP_NE => '!=',
  41346. );
  41347. protected $operator;
  41348. protected $version;
  41349. protected $prettyString;
  41350. protected $lowerBound;
  41351. protected $upperBound;
  41352. public function __construct($operator, $version)
  41353. {
  41354. if (!isset(self::$transOpStr[$operator])) {
  41355. throw new \InvalidArgumentException(sprintf(
  41356. 'Invalid operator "%s" given, expected one of: %s',
  41357. $operator,
  41358. implode(', ', self::getSupportedOperators())
  41359. ));
  41360. }
  41361. $this->operator = self::$transOpStr[$operator];
  41362. $this->version = $version;
  41363. }
  41364. public function getVersion()
  41365. {
  41366. return $this->version;
  41367. }
  41368. public function getOperator()
  41369. {
  41370. return self::$transOpInt[$this->operator];
  41371. }
  41372. public function matches(ConstraintInterface $provider)
  41373. {
  41374. if ($provider instanceof self) {
  41375. return $this->matchSpecific($provider);
  41376. }
  41377. return $provider->matches($this);
  41378. }
  41379. public function setPrettyString($prettyString)
  41380. {
  41381. $this->prettyString = $prettyString;
  41382. }
  41383. public function getPrettyString()
  41384. {
  41385. if ($this->prettyString) {
  41386. return $this->prettyString;
  41387. }
  41388. return $this->__toString();
  41389. }
  41390. public static function getSupportedOperators()
  41391. {
  41392. return array_keys(self::$transOpStr);
  41393. }
  41394. public static function getOperatorConstant($operator)
  41395. {
  41396. return self::$transOpStr[$operator];
  41397. }
  41398. public function versionCompare($a, $b, $operator, $compareBranches = false)
  41399. {
  41400. if (!isset(self::$transOpStr[$operator])) {
  41401. throw new \InvalidArgumentException(sprintf(
  41402. 'Invalid operator "%s" given, expected one of: %s',
  41403. $operator,
  41404. implode(', ', self::getSupportedOperators())
  41405. ));
  41406. }
  41407. $aIsBranch = strpos($a, 'dev-') === 0;
  41408. $bIsBranch = strpos($b, 'dev-') === 0;
  41409. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  41410. return $a !== $b;
  41411. }
  41412. if ($aIsBranch && $bIsBranch) {
  41413. return $operator === '==' && $a === $b;
  41414. }
  41415. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  41416. return false;
  41417. }
  41418. return \version_compare($a, $b, $operator);
  41419. }
  41420. public function compile($otherOperator)
  41421. {
  41422. if (strpos($this->version, 'dev-') === 0) {
  41423. if (self::OP_EQ === $this->operator) {
  41424. if (self::OP_EQ === $otherOperator) {
  41425. return sprintf('$b && $v === %s', \var_export($this->version, true));
  41426. }
  41427. if (self::OP_NE === $otherOperator) {
  41428. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  41429. }
  41430. return 'false';
  41431. }
  41432. if (self::OP_NE === $this->operator) {
  41433. if (self::OP_EQ === $otherOperator) {
  41434. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  41435. }
  41436. if (self::OP_NE === $otherOperator) {
  41437. return 'true';
  41438. }
  41439. return '!$b';
  41440. }
  41441. return 'false';
  41442. }
  41443. if (self::OP_EQ === $this->operator) {
  41444. if (self::OP_EQ === $otherOperator) {
  41445. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  41446. }
  41447. if (self::OP_NE === $otherOperator) {
  41448. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  41449. }
  41450. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  41451. }
  41452. if (self::OP_NE === $this->operator) {
  41453. if (self::OP_EQ === $otherOperator) {
  41454. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  41455. }
  41456. if (self::OP_NE === $otherOperator) {
  41457. return 'true';
  41458. }
  41459. return '!$b';
  41460. }
  41461. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  41462. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  41463. return '!$b';
  41464. }
  41465. } else {
  41466. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  41467. return '!$b';
  41468. }
  41469. }
  41470. if (self::OP_NE === $otherOperator) {
  41471. return 'true';
  41472. }
  41473. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  41474. if ($this->operator === self::OP_LE) {
  41475. if ($otherOperator === self::OP_GT) {
  41476. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  41477. }
  41478. } elseif ($this->operator === self::OP_GE) {
  41479. if ($otherOperator === self::OP_LT) {
  41480. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  41481. }
  41482. }
  41483. return sprintf('!$b && %s', $codeComparison);
  41484. }
  41485. public function matchSpecific(Constraint $provider, $compareBranches = false)
  41486. {
  41487. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  41488. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  41489. $isEqualOp = self::OP_EQ === $this->operator;
  41490. $isNonEqualOp = self::OP_NE === $this->operator;
  41491. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  41492. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  41493. if ($isNonEqualOp || $isProviderNonEqualOp) {
  41494. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  41495. return false;
  41496. }
  41497. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  41498. return false;
  41499. }
  41500. if (!$isEqualOp && !$isProviderEqualOp) {
  41501. return true;
  41502. }
  41503. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  41504. }
  41505. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  41506. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  41507. }
  41508. $version1 = $isEqualOp ? $this->version : $provider->version;
  41509. $version2 = $isEqualOp ? $provider->version : $this->version;
  41510. $operator = $isEqualOp ? $provider->operator : $this->operator;
  41511. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  41512. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  41513. && self::$transOpInt[$this->operator] !== $noEqualOp
  41514. && \version_compare($provider->version, $this->version, '=='));
  41515. }
  41516. return false;
  41517. }
  41518. public function __toString()
  41519. {
  41520. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  41521. }
  41522. public function getLowerBound()
  41523. {
  41524. $this->extractBounds();
  41525. return $this->lowerBound;
  41526. }
  41527. public function getUpperBound()
  41528. {
  41529. $this->extractBounds();
  41530. return $this->upperBound;
  41531. }
  41532. private function extractBounds()
  41533. {
  41534. if (null !== $this->lowerBound) {
  41535. return;
  41536. }
  41537. if (strpos($this->version, 'dev-') === 0) {
  41538. $this->lowerBound = Bound::zero();
  41539. $this->upperBound = Bound::positiveInfinity();
  41540. return;
  41541. }
  41542. switch ($this->operator) {
  41543. case self::OP_EQ:
  41544. $this->lowerBound = new Bound($this->version, true);
  41545. $this->upperBound = new Bound($this->version, true);
  41546. break;
  41547. case self::OP_LT:
  41548. $this->lowerBound = Bound::zero();
  41549. $this->upperBound = new Bound($this->version, false);
  41550. break;
  41551. case self::OP_LE:
  41552. $this->lowerBound = Bound::zero();
  41553. $this->upperBound = new Bound($this->version, true);
  41554. break;
  41555. case self::OP_GT:
  41556. $this->lowerBound = new Bound($this->version, false);
  41557. $this->upperBound = Bound::positiveInfinity();
  41558. break;
  41559. case self::OP_GE:
  41560. $this->lowerBound = new Bound($this->version, true);
  41561. $this->upperBound = Bound::positiveInfinity();
  41562. break;
  41563. case self::OP_NE:
  41564. $this->lowerBound = Bound::zero();
  41565. $this->upperBound = Bound::positiveInfinity();
  41566. break;
  41567. }
  41568. }
  41569. }
  41570. <?php
  41571. namespace Composer\Semver\Constraint;
  41572. interface ConstraintInterface
  41573. {
  41574. public function matches(ConstraintInterface $provider);
  41575. public function compile($otherOperator);
  41576. public function getUpperBound();
  41577. public function getLowerBound();
  41578. public function getPrettyString();
  41579. public function setPrettyString($prettyString);
  41580. public function __toString();
  41581. }
  41582. <?php
  41583. namespace Composer\Semver\Constraint;
  41584. class MatchAllConstraint implements ConstraintInterface
  41585. {
  41586. protected $prettyString;
  41587. public function matches(ConstraintInterface $provider)
  41588. {
  41589. return true;
  41590. }
  41591. public function compile($otherOperator)
  41592. {
  41593. return 'true';
  41594. }
  41595. public function setPrettyString($prettyString)
  41596. {
  41597. $this->prettyString = $prettyString;
  41598. }
  41599. public function getPrettyString()
  41600. {
  41601. if ($this->prettyString) {
  41602. return $this->prettyString;
  41603. }
  41604. return (string) $this;
  41605. }
  41606. public function __toString()
  41607. {
  41608. return '*';
  41609. }
  41610. public function getUpperBound()
  41611. {
  41612. return Bound::positiveInfinity();
  41613. }
  41614. public function getLowerBound()
  41615. {
  41616. return Bound::zero();
  41617. }
  41618. }
  41619. <?php
  41620. namespace Composer\Semver\Constraint;
  41621. class MatchNoneConstraint implements ConstraintInterface
  41622. {
  41623. protected $prettyString;
  41624. public function matches(ConstraintInterface $provider)
  41625. {
  41626. return false;
  41627. }
  41628. public function compile($otherOperator)
  41629. {
  41630. return 'false';
  41631. }
  41632. public function setPrettyString($prettyString)
  41633. {
  41634. $this->prettyString = $prettyString;
  41635. }
  41636. public function getPrettyString()
  41637. {
  41638. if ($this->prettyString) {
  41639. return $this->prettyString;
  41640. }
  41641. return (string) $this;
  41642. }
  41643. public function __toString()
  41644. {
  41645. return '[]';
  41646. }
  41647. public function getUpperBound()
  41648. {
  41649. return new Bound('0.0.0.0-dev', false);
  41650. }
  41651. public function getLowerBound()
  41652. {
  41653. return new Bound('0.0.0.0-dev', false);
  41654. }
  41655. }
  41656. <?php
  41657. namespace Composer\Semver\Constraint;
  41658. class MultiConstraint implements ConstraintInterface
  41659. {
  41660. protected $constraints;
  41661. protected $prettyString;
  41662. protected $string;
  41663. protected $conjunctive;
  41664. protected $lowerBound;
  41665. protected $upperBound;
  41666. public function __construct(array $constraints, $conjunctive = true)
  41667. {
  41668. if (\count($constraints) < 2) {
  41669. throw new \InvalidArgumentException(
  41670. 'Must provide at least two constraints for a MultiConstraint. Use '.
  41671. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  41672. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  41673. );
  41674. }
  41675. $this->constraints = $constraints;
  41676. $this->conjunctive = $conjunctive;
  41677. }
  41678. public function getConstraints()
  41679. {
  41680. return $this->constraints;
  41681. }
  41682. public function isConjunctive()
  41683. {
  41684. return $this->conjunctive;
  41685. }
  41686. public function isDisjunctive()
  41687. {
  41688. return !$this->conjunctive;
  41689. }
  41690. public function compile($otherOperator)
  41691. {
  41692. $parts = array();
  41693. foreach ($this->constraints as $constraint) {
  41694. $code = $constraint->compile($otherOperator);
  41695. if ($code === 'true') {
  41696. if (!$this->conjunctive) {
  41697. return 'true';
  41698. }
  41699. } elseif ($code === 'false') {
  41700. if ($this->conjunctive) {
  41701. return 'false';
  41702. }
  41703. } else {
  41704. $parts[] = '('.$code.')';
  41705. }
  41706. }
  41707. if (!$parts) {
  41708. return $this->conjunctive ? 'true' : 'false';
  41709. }
  41710. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  41711. }
  41712. public function matches(ConstraintInterface $provider)
  41713. {
  41714. if (false === $this->conjunctive) {
  41715. foreach ($this->constraints as $constraint) {
  41716. if ($provider->matches($constraint)) {
  41717. return true;
  41718. }
  41719. }
  41720. return false;
  41721. }
  41722. if ($provider instanceof MultiConstraint && $provider->isDisjunctive()) {
  41723. return $provider->matches($this);
  41724. }
  41725. foreach ($this->constraints as $constraint) {
  41726. if (!$provider->matches($constraint)) {
  41727. return false;
  41728. }
  41729. }
  41730. return true;
  41731. }
  41732. public function setPrettyString($prettyString)
  41733. {
  41734. $this->prettyString = $prettyString;
  41735. }
  41736. public function getPrettyString()
  41737. {
  41738. if ($this->prettyString) {
  41739. return $this->prettyString;
  41740. }
  41741. return (string) $this;
  41742. }
  41743. public function __toString()
  41744. {
  41745. if ($this->string !== null) {
  41746. return $this->string;
  41747. }
  41748. $constraints = array();
  41749. foreach ($this->constraints as $constraint) {
  41750. $constraints[] = (string) $constraint;
  41751. }
  41752. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  41753. }
  41754. public function getLowerBound()
  41755. {
  41756. $this->extractBounds();
  41757. if (null === $this->lowerBound) {
  41758. throw new \LogicException('extractBounds should have populated the lowerBound property');
  41759. }
  41760. return $this->lowerBound;
  41761. }
  41762. public function getUpperBound()
  41763. {
  41764. $this->extractBounds();
  41765. if (null === $this->upperBound) {
  41766. throw new \LogicException('extractBounds should have populated the upperBound property');
  41767. }
  41768. return $this->upperBound;
  41769. }
  41770. public static function create(array $constraints, $conjunctive = true)
  41771. {
  41772. if (0 === \count($constraints)) {
  41773. return new MatchAllConstraint();
  41774. }
  41775. if (1 === \count($constraints)) {
  41776. return $constraints[0];
  41777. }
  41778. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  41779. if ($optimized !== null) {
  41780. list($constraints, $conjunctive) = $optimized;
  41781. if (\count($constraints) === 1) {
  41782. return $constraints[0];
  41783. }
  41784. }
  41785. return new self($constraints, $conjunctive);
  41786. }
  41787. private static function optimizeConstraints(array $constraints, $conjunctive)
  41788. {
  41789. if (!$conjunctive) {
  41790. $left = $constraints[0];
  41791. $mergedConstraints = array();
  41792. $optimized = false;
  41793. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  41794. $right = $constraints[$i];
  41795. if (
  41796. $left instanceof self
  41797. && $left->conjunctive
  41798. && $right instanceof self
  41799. && $right->conjunctive
  41800. && \count($left->constraints) === 2
  41801. && \count($right->constraints) === 2
  41802. && ($left0 = (string) $left->constraints[0])
  41803. && $left0[0] === '>' && $left0[1] === '='
  41804. && ($left1 = (string) $left->constraints[1])
  41805. && $left1[0] === '<'
  41806. && ($right0 = (string) $right->constraints[0])
  41807. && $right0[0] === '>' && $right0[1] === '='
  41808. && ($right1 = (string) $right->constraints[1])
  41809. && $right1[0] === '<'
  41810. && substr($left1, 2) === substr($right0, 3)
  41811. ) {
  41812. $optimized = true;
  41813. $left = new MultiConstraint(
  41814. array(
  41815. $left->constraints[0],
  41816. $right->constraints[1],
  41817. ),
  41818. true);
  41819. } else {
  41820. $mergedConstraints[] = $left;
  41821. $left = $right;
  41822. }
  41823. }
  41824. if ($optimized) {
  41825. $mergedConstraints[] = $left;
  41826. return array($mergedConstraints, false);
  41827. }
  41828. }
  41829. return null;
  41830. }
  41831. private function extractBounds()
  41832. {
  41833. if (null !== $this->lowerBound) {
  41834. return;
  41835. }
  41836. foreach ($this->constraints as $constraint) {
  41837. if (null === $this->lowerBound || null === $this->upperBound) {
  41838. $this->lowerBound = $constraint->getLowerBound();
  41839. $this->upperBound = $constraint->getUpperBound();
  41840. continue;
  41841. }
  41842. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  41843. $this->lowerBound = $constraint->getLowerBound();
  41844. }
  41845. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  41846. $this->upperBound = $constraint->getUpperBound();
  41847. }
  41848. }
  41849. }
  41850. }
  41851. <?php
  41852. namespace Composer\Semver;
  41853. use Composer\Semver\Constraint\Constraint;
  41854. class Interval
  41855. {
  41856. private $start;
  41857. private $end;
  41858. public function __construct(Constraint $start, Constraint $end)
  41859. {
  41860. $this->start = $start;
  41861. $this->end = $end;
  41862. }
  41863. public function getStart()
  41864. {
  41865. return $this->start;
  41866. }
  41867. public function getEnd()
  41868. {
  41869. return $this->end;
  41870. }
  41871. public static function fromZero()
  41872. {
  41873. static $zero;
  41874. if (null === $zero) {
  41875. $zero = new Constraint('>=', '0.0.0.0-dev');
  41876. }
  41877. return $zero;
  41878. }
  41879. public static function untilPositiveInfinity()
  41880. {
  41881. static $positiveInfinity;
  41882. if (null === $positiveInfinity) {
  41883. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  41884. }
  41885. return $positiveInfinity;
  41886. }
  41887. public static function any()
  41888. {
  41889. return new self(self::fromZero(), self::untilPositiveInfinity());
  41890. }
  41891. public static function anyDev()
  41892. {
  41893. return array('names' => array(), 'exclude' => true);
  41894. }
  41895. public static function noDev()
  41896. {
  41897. return array('names' => array(), 'exclude' => false);
  41898. }
  41899. }
  41900. <?php
  41901. namespace Composer\Semver;
  41902. use Composer\Semver\Constraint\Constraint;
  41903. use Composer\Semver\Constraint\ConstraintInterface;
  41904. use Composer\Semver\Constraint\MatchAllConstraint;
  41905. use Composer\Semver\Constraint\MatchNoneConstraint;
  41906. use Composer\Semver\Constraint\MultiConstraint;
  41907. class Intervals
  41908. {
  41909. private static $intervalsCache = array();
  41910. private static $opSortOrder = array(
  41911. '>=' => -3,
  41912. '<' => -2,
  41913. '>' => 2,
  41914. '<=' => 3,
  41915. );
  41916. public static function clear()
  41917. {
  41918. self::$intervalsCache = array();
  41919. }
  41920. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  41921. {
  41922. if ($constraint instanceof MatchAllConstraint) {
  41923. return true;
  41924. }
  41925. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  41926. return false;
  41927. }
  41928. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  41929. $candidateIntervals = self::get($candidate);
  41930. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  41931. return false;
  41932. }
  41933. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  41934. if (!isset($candidateIntervals['numeric'][$index])) {
  41935. return false;
  41936. }
  41937. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  41938. return false;
  41939. }
  41940. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  41941. return false;
  41942. }
  41943. }
  41944. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  41945. return false;
  41946. }
  41947. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  41948. return false;
  41949. }
  41950. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  41951. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  41952. return false;
  41953. }
  41954. }
  41955. return true;
  41956. }
  41957. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  41958. {
  41959. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  41960. return true;
  41961. }
  41962. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  41963. return false;
  41964. }
  41965. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  41966. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  41967. }
  41968. public static function compactConstraint(ConstraintInterface $constraint)
  41969. {
  41970. if (!$constraint instanceof MultiConstraint) {
  41971. return $constraint;
  41972. }
  41973. $intervals = self::generateIntervals($constraint);
  41974. $constraints = array();
  41975. $hasNumericMatchAll = false;
  41976. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  41977. $constraints[] = $intervals['numeric'][0]->getStart();
  41978. $hasNumericMatchAll = true;
  41979. } else {
  41980. $unEqualConstraints = array();
  41981. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  41982. $interval = $intervals['numeric'][$i];
  41983. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  41984. $nextInterval = $intervals['numeric'][$i+1];
  41985. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  41986. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  41987. $unEqualConstraints[] = $interval->getStart();
  41988. }
  41989. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  41990. continue;
  41991. }
  41992. }
  41993. if (\count($unEqualConstraints) > 0) {
  41994. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  41995. $unEqualConstraints[] = $interval->getEnd();
  41996. }
  41997. if (\count($unEqualConstraints) > 1) {
  41998. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  41999. } else {
  42000. $constraints[] = $unEqualConstraints[0];
  42001. }
  42002. $unEqualConstraints = array();
  42003. continue;
  42004. }
  42005. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  42006. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  42007. continue;
  42008. }
  42009. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  42010. $constraints[] = $interval->getEnd();
  42011. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  42012. $constraints[] = $interval->getStart();
  42013. } else {
  42014. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  42015. }
  42016. }
  42017. }
  42018. $devConstraints = array();
  42019. if (0 === \count($intervals['branches']['names'])) {
  42020. if ($intervals['branches']['exclude']) {
  42021. if ($hasNumericMatchAll) {
  42022. return new MatchAllConstraint;
  42023. }
  42024. }
  42025. } else {
  42026. foreach ($intervals['branches']['names'] as $branchName) {
  42027. if ($intervals['branches']['exclude']) {
  42028. $devConstraints[] = new Constraint('!=', $branchName);
  42029. } else {
  42030. $devConstraints[] = new Constraint('==', $branchName);
  42031. }
  42032. }
  42033. if ($intervals['branches']['exclude']) {
  42034. if (\count($constraints) > 1) {
  42035. return new MultiConstraint(array_merge(
  42036. array(new MultiConstraint($constraints, false)),
  42037. $devConstraints
  42038. ), true);
  42039. }
  42040. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  42041. if (\count($devConstraints) > 1) {
  42042. return new MultiConstraint($devConstraints, true);
  42043. }
  42044. return $devConstraints[0];
  42045. }
  42046. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  42047. }
  42048. $constraints = array_merge($constraints, $devConstraints);
  42049. }
  42050. if (\count($constraints) > 1) {
  42051. return new MultiConstraint($constraints, false);
  42052. }
  42053. if (\count($constraints) === 1) {
  42054. return $constraints[0];
  42055. }
  42056. return new MatchNoneConstraint;
  42057. }
  42058. public static function get(ConstraintInterface $constraint)
  42059. {
  42060. $key = (string) $constraint;
  42061. if (!isset(self::$intervalsCache[$key])) {
  42062. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  42063. }
  42064. return self::$intervalsCache[$key];
  42065. }
  42066. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  42067. {
  42068. if ($constraint instanceof MatchAllConstraint) {
  42069. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  42070. }
  42071. if ($constraint instanceof MatchNoneConstraint) {
  42072. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  42073. }
  42074. if ($constraint instanceof Constraint) {
  42075. return self::generateSingleConstraintIntervals($constraint);
  42076. }
  42077. if (!$constraint instanceof MultiConstraint) {
  42078. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  42079. }
  42080. $constraints = $constraint->getConstraints();
  42081. $numericGroups = array();
  42082. $constraintBranches = array();
  42083. foreach ($constraints as $c) {
  42084. $res = self::get($c);
  42085. $numericGroups[] = $res['numeric'];
  42086. $constraintBranches[] = $res['branches'];
  42087. }
  42088. if ($constraint->isDisjunctive()) {
  42089. $branches = Interval::noDev();
  42090. foreach ($constraintBranches as $b) {
  42091. if ($b['exclude']) {
  42092. if ($branches['exclude']) {
  42093. $branches['names'] = array_intersect($branches['names'], $b['names']);
  42094. } else {
  42095. $branches['exclude'] = true;
  42096. $branches['names'] = array_diff($b['names'], $branches['names']);
  42097. }
  42098. } else {
  42099. if ($branches['exclude']) {
  42100. $branches['names'] = array_diff($branches['names'], $b['names']);
  42101. } else {
  42102. $branches['names'] = array_merge($branches['names'], $b['names']);
  42103. }
  42104. }
  42105. }
  42106. } else {
  42107. $branches = Interval::anyDev();
  42108. foreach ($constraintBranches as $b) {
  42109. if ($b['exclude']) {
  42110. if ($branches['exclude']) {
  42111. $branches['names'] = array_merge($branches['names'], $b['names']);
  42112. } else {
  42113. $branches['names'] = array_diff($branches['names'], $b['names']);
  42114. }
  42115. } else {
  42116. if ($branches['exclude']) {
  42117. $branches['names'] = array_diff($b['names'], $branches['names']);
  42118. $branches['exclude'] = false;
  42119. } else {
  42120. $branches['names'] = array_intersect($branches['names'], $b['names']);
  42121. }
  42122. }
  42123. }
  42124. }
  42125. $branches['names'] = array_unique($branches['names']);
  42126. if (\count($numericGroups) === 1) {
  42127. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  42128. }
  42129. $borders = array();
  42130. foreach ($numericGroups as $group) {
  42131. foreach ($group as $interval) {
  42132. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  42133. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  42134. }
  42135. }
  42136. $opSortOrder = self::$opSortOrder;
  42137. usort($borders, function ($a, $b) use ($opSortOrder) {
  42138. $order = version_compare($a['version'], $b['version']);
  42139. if ($order === 0) {
  42140. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  42141. }
  42142. return $order;
  42143. });
  42144. $activeIntervals = 0;
  42145. $intervals = array();
  42146. $index = 0;
  42147. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  42148. $start = null;
  42149. foreach ($borders as $border) {
  42150. if ($border['side'] === 'start') {
  42151. $activeIntervals++;
  42152. } else {
  42153. $activeIntervals--;
  42154. }
  42155. if (!$start && $activeIntervals >= $activationThreshold) {
  42156. $start = new Constraint($border['operator'], $border['version']);
  42157. } elseif ($start && $activeIntervals < $activationThreshold) {
  42158. if (
  42159. version_compare($start->getVersion(), $border['version'], '=')
  42160. && (
  42161. ($start->getOperator() === '>' && $border['operator'] === '<=')
  42162. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  42163. )
  42164. ) {
  42165. unset($intervals[$index]);
  42166. } else {
  42167. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  42168. $index++;
  42169. if ($stopOnFirstValidInterval) {
  42170. break;
  42171. }
  42172. }
  42173. $start = null;
  42174. }
  42175. }
  42176. return array('numeric' => $intervals, 'branches' => $branches);
  42177. }
  42178. private static function generateSingleConstraintIntervals(Constraint $constraint)
  42179. {
  42180. $op = $constraint->getOperator();
  42181. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  42182. $intervals = array();
  42183. $branches = array('names' => array(), 'exclude' => false);
  42184. if ($op === '!=') {
  42185. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  42186. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  42187. } elseif ($op === '==') {
  42188. $branches['names'][] = $constraint->getVersion();
  42189. }
  42190. return array(
  42191. 'numeric' => $intervals,
  42192. 'branches' => $branches,
  42193. );
  42194. }
  42195. if ($op[0] === '>') {
  42196. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  42197. }
  42198. if ($op[0] === '<') {
  42199. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  42200. }
  42201. if ($op === '!=') {
  42202. return array('numeric' => array(
  42203. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  42204. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  42205. ), 'branches' => Interval::anyDev());
  42206. }
  42207. return array('numeric' => array(
  42208. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  42209. ), 'branches' => Interval::noDev());
  42210. }
  42211. }
  42212. <?php
  42213. namespace Composer\Semver;
  42214. use Composer\Semver\Constraint\Constraint;
  42215. class Semver
  42216. {
  42217. const SORT_ASC = 1;
  42218. const SORT_DESC = -1;
  42219. private static $versionParser;
  42220. public static function satisfies($version, $constraints)
  42221. {
  42222. if (null === self::$versionParser) {
  42223. self::$versionParser = new VersionParser();
  42224. }
  42225. $versionParser = self::$versionParser;
  42226. $provider = new Constraint('==', $versionParser->normalize($version));
  42227. $parsedConstraints = $versionParser->parseConstraints($constraints);
  42228. return $parsedConstraints->matches($provider);
  42229. }
  42230. public static function satisfiedBy(array $versions, $constraints)
  42231. {
  42232. $versions = array_filter($versions, function ($version) use ($constraints) {
  42233. return Semver::satisfies($version, $constraints);
  42234. });
  42235. return array_values($versions);
  42236. }
  42237. public static function sort(array $versions)
  42238. {
  42239. return self::usort($versions, self::SORT_ASC);
  42240. }
  42241. public static function rsort(array $versions)
  42242. {
  42243. return self::usort($versions, self::SORT_DESC);
  42244. }
  42245. private static function usort(array $versions, $direction)
  42246. {
  42247. if (null === self::$versionParser) {
  42248. self::$versionParser = new VersionParser();
  42249. }
  42250. $versionParser = self::$versionParser;
  42251. $normalized = array();
  42252. foreach ($versions as $key => $version) {
  42253. $normalizedVersion = $versionParser->normalize($version);
  42254. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  42255. $normalized[] = array($normalizedVersion, $key);
  42256. }
  42257. usort($normalized, function (array $left, array $right) use ($direction) {
  42258. if ($left[0] === $right[0]) {
  42259. return 0;
  42260. }
  42261. if (Comparator::lessThan($left[0], $right[0])) {
  42262. return -$direction;
  42263. }
  42264. return $direction;
  42265. });
  42266. $sorted = array();
  42267. foreach ($normalized as $item) {
  42268. $sorted[] = $versions[$item[1]];
  42269. }
  42270. return $sorted;
  42271. }
  42272. }
  42273. <?php
  42274. namespace Composer\Semver;
  42275. use Composer\Semver\Constraint\ConstraintInterface;
  42276. use Composer\Semver\Constraint\MatchAllConstraint;
  42277. use Composer\Semver\Constraint\MultiConstraint;
  42278. use Composer\Semver\Constraint\Constraint;
  42279. class VersionParser
  42280. {
  42281. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  42282. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  42283. public static function parseStability($version)
  42284. {
  42285. $version = (string) preg_replace('{#.+$}', '', $version);
  42286. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  42287. return 'dev';
  42288. }
  42289. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  42290. if (!empty($match[3])) {
  42291. return 'dev';
  42292. }
  42293. if (!empty($match[1])) {
  42294. if ('beta' === $match[1] || 'b' === $match[1]) {
  42295. return 'beta';
  42296. }
  42297. if ('alpha' === $match[1] || 'a' === $match[1]) {
  42298. return 'alpha';
  42299. }
  42300. if ('rc' === $match[1]) {
  42301. return 'RC';
  42302. }
  42303. }
  42304. return 'stable';
  42305. }
  42306. public static function normalizeStability($stability)
  42307. {
  42308. $stability = strtolower($stability);
  42309. return $stability === 'rc' ? 'RC' : $stability;
  42310. }
  42311. public function normalize($version, $fullVersion = null)
  42312. {
  42313. $version = trim($version);
  42314. $origVersion = $version;
  42315. if (null === $fullVersion) {
  42316. $fullVersion = $version;
  42317. }
  42318. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  42319. $version = $match[1];
  42320. }
  42321. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  42322. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  42323. }
  42324. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  42325. $version = 'dev-' . $version;
  42326. }
  42327. if (stripos($version, 'dev-') === 0) {
  42328. return 'dev-' . substr($version, 4);
  42329. }
  42330. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  42331. $version = $match[1];
  42332. }
  42333. if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  42334. $version = $matches[1]
  42335. . (!empty($matches[2]) ? $matches[2] : '.0')
  42336. . (!empty($matches[3]) ? $matches[3] : '.0')
  42337. . (!empty($matches[4]) ? $matches[4] : '.0');
  42338. $index = 5;
  42339. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
  42340. $version = preg_replace('{\D}', '.', $matches[1]);
  42341. $index = 2;
  42342. }
  42343. if (isset($index)) {
  42344. if (!empty($matches[$index])) {
  42345. if ('stable' === $matches[$index]) {
  42346. return $version;
  42347. }
  42348. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  42349. }
  42350. if (!empty($matches[$index + 2])) {
  42351. $version .= '-dev';
  42352. }
  42353. return $version;
  42354. }
  42355. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  42356. try {
  42357. $normalized = $this->normalizeBranch($match[1]);
  42358. if (strpos($normalized, 'dev-') === false) {
  42359. return $normalized;
  42360. }
  42361. } catch (\Exception $e) {
  42362. }
  42363. }
  42364. $extraMessage = '';
  42365. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  42366. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  42367. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  42368. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  42369. }
  42370. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  42371. }
  42372. public function parseNumericAliasPrefix($branch)
  42373. {
  42374. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', $branch, $matches)) {
  42375. return $matches['version'] . '.';
  42376. }
  42377. return false;
  42378. }
  42379. public function normalizeBranch($name)
  42380. {
  42381. $name = trim($name);
  42382. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  42383. $version = '';
  42384. for ($i = 1; $i < 5; ++$i) {
  42385. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  42386. }
  42387. return str_replace('x', '9999999', $version) . '-dev';
  42388. }
  42389. return 'dev-' . $name;
  42390. }
  42391. public function normalizeDefaultBranch($name)
  42392. {
  42393. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  42394. return '9999999-dev';
  42395. }
  42396. return $name;
  42397. }
  42398. public function parseConstraints($constraints)
  42399. {
  42400. $prettyConstraint = $constraints;
  42401. $orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));
  42402. if (false === $orConstraints) {
  42403. throw new \RuntimeException('Failed to preg_split string: '.$constraints);
  42404. }
  42405. $orGroups = array();
  42406. foreach ($orConstraints as $constraints) {
  42407. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
  42408. if (false === $andConstraints) {
  42409. throw new \RuntimeException('Failed to preg_split string: '.$constraints);
  42410. }
  42411. if (\count($andConstraints) > 1) {
  42412. $constraintObjects = array();
  42413. foreach ($andConstraints as $constraint) {
  42414. foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
  42415. $constraintObjects[] = $parsedConstraint;
  42416. }
  42417. }
  42418. } else {
  42419. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  42420. }
  42421. if (1 === \count($constraintObjects)) {
  42422. $constraint = $constraintObjects[0];
  42423. } else {
  42424. $constraint = new MultiConstraint($constraintObjects);
  42425. }
  42426. $orGroups[] = $constraint;
  42427. }
  42428. $constraint = MultiConstraint::create($orGroups, false);
  42429. $constraint->setPrettyString($prettyConstraint);
  42430. return $constraint;
  42431. }
  42432. private function parseConstraint($constraint)
  42433. {
  42434. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  42435. $constraint = $match[1];
  42436. }
  42437. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  42438. $constraint = '' !== $match[1] ? $match[1] : '*';
  42439. if ($match[2] !== 'stable') {
  42440. $stabilityModifier = $match[2];
  42441. }
  42442. }
  42443. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  42444. $constraint = $match[1];
  42445. }
  42446. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  42447. if (!empty($match[1]) || !empty($match[2])) {
  42448. return array(new Constraint('>=', '0.0.0.0-dev'));
  42449. }
  42450. return array(new MatchAllConstraint());
  42451. }
  42452. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  42453. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  42454. if (strpos($constraint, '~>') === 0) {
  42455. throw new \UnexpectedValueException(
  42456. 'Could not parse version constraint ' . $constraint . ': ' .
  42457. 'Invalid operator "~>", you probably meant to use the "~" operator'
  42458. );
  42459. }
  42460. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  42461. $position = 4;
  42462. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  42463. $position = 3;
  42464. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  42465. $position = 2;
  42466. } else {
  42467. $position = 1;
  42468. }
  42469. if (!empty($matches[8])) {
  42470. $position++;
  42471. }
  42472. $stabilitySuffix = '';
  42473. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  42474. $stabilitySuffix .= '-dev';
  42475. }
  42476. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  42477. $lowerBound = new Constraint('>=', $lowVersion);
  42478. $highPosition = max(1, $position - 1);
  42479. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  42480. $upperBound = new Constraint('<', $highVersion);
  42481. return array(
  42482. $lowerBound,
  42483. $upperBound,
  42484. );
  42485. }
  42486. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  42487. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  42488. $position = 1;
  42489. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  42490. $position = 2;
  42491. } else {
  42492. $position = 3;
  42493. }
  42494. $stabilitySuffix = '';
  42495. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  42496. $stabilitySuffix .= '-dev';
  42497. }
  42498. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  42499. $lowerBound = new Constraint('>=', $lowVersion);
  42500. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  42501. $upperBound = new Constraint('<', $highVersion);
  42502. return array(
  42503. $lowerBound,
  42504. $upperBound,
  42505. );
  42506. }
  42507. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  42508. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  42509. $position = 3;
  42510. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  42511. $position = 2;
  42512. } else {
  42513. $position = 1;
  42514. }
  42515. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  42516. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  42517. if ($lowVersion === '0.0.0.0-dev') {
  42518. return array(new Constraint('<', $highVersion));
  42519. }
  42520. return array(
  42521. new Constraint('>=', $lowVersion),
  42522. new Constraint('<', $highVersion),
  42523. );
  42524. }
  42525. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  42526. $lowStabilitySuffix = '';
  42527. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  42528. $lowStabilitySuffix = '-dev';
  42529. }
  42530. $lowVersion = $this->normalize($matches['from']);
  42531. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  42532. $empty = function ($x) {
  42533. return ($x === 0 || $x === '0') ? false : empty($x);
  42534. };
  42535. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  42536. $highVersion = $this->normalize($matches['to']);
  42537. $upperBound = new Constraint('<=', $highVersion);
  42538. } else {
  42539. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  42540. $this->normalize($matches['to']);
  42541. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  42542. $upperBound = new Constraint('<', $highVersion);
  42543. }
  42544. return array(
  42545. $lowerBound,
  42546. $upperBound,
  42547. );
  42548. }
  42549. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  42550. try {
  42551. try {
  42552. $version = $this->normalize($matches[2]);
  42553. } catch (\UnexpectedValueException $e) {
  42554. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  42555. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  42556. } else {
  42557. throw $e;
  42558. }
  42559. }
  42560. $op = $matches[1] ?: '=';
  42561. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  42562. $version .= '-' . $stabilityModifier;
  42563. } elseif ('<' === $op || '>=' === $op) {
  42564. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  42565. if (strpos($matches[2], 'dev-') !== 0) {
  42566. $version .= '-dev';
  42567. }
  42568. }
  42569. }
  42570. return array(new Constraint($matches[1] ?: '=', $version));
  42571. } catch (\Exception $e) {
  42572. }
  42573. }
  42574. $message = 'Could not parse version constraint ' . $constraint;
  42575. if (isset($e)) {
  42576. $message .= ': ' . $e->getMessage();
  42577. }
  42578. throw new \UnexpectedValueException($message);
  42579. }
  42580. private function manipulateVersionString(array $matches, $position, $increment = 0, $pad = '0')
  42581. {
  42582. for ($i = 4; $i > 0; --$i) {
  42583. if ($i > $position) {
  42584. $matches[$i] = $pad;
  42585. } elseif ($i === $position && $increment) {
  42586. $matches[$i] += $increment;
  42587. if ($matches[$i] < 0) {
  42588. $matches[$i] = $pad;
  42589. --$position;
  42590. if ($i === 1) {
  42591. return null;
  42592. }
  42593. }
  42594. }
  42595. }
  42596. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  42597. }
  42598. private function expandStability($stability)
  42599. {
  42600. $stability = strtolower($stability);
  42601. switch ($stability) {
  42602. case 'a':
  42603. return 'alpha';
  42604. case 'b':
  42605. return 'beta';
  42606. case 'p':
  42607. case 'pl':
  42608. return 'patch';
  42609. case 'rc':
  42610. return 'RC';
  42611. default:
  42612. return $stability;
  42613. }
  42614. }
  42615. }
  42616. Copyright (C) 2015 Composer
  42617. Permission is hereby granted, free of charge, to any person obtaining a copy of
  42618. this software and associated documentation files (the "Software"), to deal in
  42619. the Software without restriction, including without limitation the rights to
  42620. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  42621. of the Software, and to permit persons to whom the Software is furnished to do
  42622. so, subject to the following conditions:
  42623. The above copyright notice and this permission notice shall be included in all
  42624. copies or substantial portions of the Software.
  42625. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42626. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42627. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42628. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42629. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42630. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  42631. SOFTWARE.
  42632. {
  42633. "389-exception": [
  42634. "389 Directory Server Exception"
  42635. ],
  42636. "Autoconf-exception-2.0": [
  42637. "Autoconf exception 2.0"
  42638. ],
  42639. "Autoconf-exception-3.0": [
  42640. "Autoconf exception 3.0"
  42641. ],
  42642. "Bison-exception-2.2": [
  42643. "Bison exception 2.2"
  42644. ],
  42645. "Bootloader-exception": [
  42646. "Bootloader Distribution Exception"
  42647. ],
  42648. "Classpath-exception-2.0": [
  42649. "Classpath exception 2.0"
  42650. ],
  42651. "CLISP-exception-2.0": [
  42652. "CLISP exception 2.0"
  42653. ],
  42654. "DigiRule-FOSS-exception": [
  42655. "DigiRule FOSS License Exception"
  42656. ],
  42657. "eCos-exception-2.0": [
  42658. "eCos exception 2.0"
  42659. ],
  42660. "Fawkes-Runtime-exception": [
  42661. "Fawkes Runtime Exception"
  42662. ],
  42663. "FLTK-exception": [
  42664. "FLTK exception"
  42665. ],
  42666. "Font-exception-2.0": [
  42667. "Font exception 2.0"
  42668. ],
  42669. "freertos-exception-2.0": [
  42670. "FreeRTOS Exception 2.0"
  42671. ],
  42672. "GCC-exception-2.0": [
  42673. "GCC Runtime Library exception 2.0"
  42674. ],
  42675. "GCC-exception-3.1": [
  42676. "GCC Runtime Library exception 3.1"
  42677. ],
  42678. "gnu-javamail-exception": [
  42679. "GNU JavaMail exception"
  42680. ],
  42681. "GPL-3.0-linking-exception": [
  42682. "GPL-3.0 Linking Exception"
  42683. ],
  42684. "GPL-3.0-linking-source-exception": [
  42685. "GPL-3.0 Linking Exception (with Corresponding Source)"
  42686. ],
  42687. "GPL-CC-1.0": [
  42688. "GPL Cooperation Commitment 1.0"
  42689. ],
  42690. "i2p-gpl-java-exception": [
  42691. "i2p GPL+Java Exception"
  42692. ],
  42693. "LGPL-3.0-linking-exception": [
  42694. "LGPL-3.0 Linking Exception"
  42695. ],
  42696. "Libtool-exception": [
  42697. "Libtool Exception"
  42698. ],
  42699. "Linux-syscall-note": [
  42700. "Linux Syscall Note"
  42701. ],
  42702. "LLVM-exception": [
  42703. "LLVM Exception"
  42704. ],
  42705. "LZMA-exception": [
  42706. "LZMA exception"
  42707. ],
  42708. "mif-exception": [
  42709. "Macros and Inline Functions Exception"
  42710. ],
  42711. "Nokia-Qt-exception-1.1": [
  42712. "Nokia Qt LGPL exception 1.1"
  42713. ],
  42714. "OCaml-LGPL-linking-exception": [
  42715. "OCaml LGPL Linking Exception"
  42716. ],
  42717. "OCCT-exception-1.0": [
  42718. "Open CASCADE Exception 1.0"
  42719. ],
  42720. "OpenJDK-assembly-exception-1.0": [
  42721. "OpenJDK Assembly exception 1.0"
  42722. ],
  42723. "openvpn-openssl-exception": [
  42724. "OpenVPN OpenSSL Exception"
  42725. ],
  42726. "PS-or-PDF-font-exception-20170817": [
  42727. "PS/PDF font exception (2017-08-17)"
  42728. ],
  42729. "Qt-GPL-exception-1.0": [
  42730. "Qt GPL exception 1.0"
  42731. ],
  42732. "Qt-LGPL-exception-1.1": [
  42733. "Qt LGPL exception 1.1"
  42734. ],
  42735. "Qwt-exception-1.0": [
  42736. "Qwt exception 1.0"
  42737. ],
  42738. "SHL-2.0": [
  42739. "Solderpad Hardware License v2.0"
  42740. ],
  42741. "SHL-2.1": [
  42742. "Solderpad Hardware License v2.1"
  42743. ],
  42744. "Swift-exception": [
  42745. "Swift Exception"
  42746. ],
  42747. "u-boot-exception-2.0": [
  42748. "U-Boot exception 2.0"
  42749. ],
  42750. "Universal-FOSS-exception-1.0": [
  42751. "Universal FOSS Exception, Version 1.0"
  42752. ],
  42753. "WxWindows-exception-3.1": [
  42754. "WxWindows Library Exception 3.1"
  42755. ]
  42756. }{
  42757. "0BSD": [
  42758. "BSD Zero Clause License",
  42759. true,
  42760. false
  42761. ],
  42762. "AAL": [
  42763. "Attribution Assurance License",
  42764. true,
  42765. false
  42766. ],
  42767. "Abstyles": [
  42768. "Abstyles License",
  42769. false,
  42770. false
  42771. ],
  42772. "Adobe-2006": [
  42773. "Adobe Systems Incorporated Source Code License Agreement",
  42774. false,
  42775. false
  42776. ],
  42777. "Adobe-Glyph": [
  42778. "Adobe Glyph List License",
  42779. false,
  42780. false
  42781. ],
  42782. "ADSL": [
  42783. "Amazon Digital Services License",
  42784. false,
  42785. false
  42786. ],
  42787. "AFL-1.1": [
  42788. "Academic Free License v1.1",
  42789. true,
  42790. false
  42791. ],
  42792. "AFL-1.2": [
  42793. "Academic Free License v1.2",
  42794. true,
  42795. false
  42796. ],
  42797. "AFL-2.0": [
  42798. "Academic Free License v2.0",
  42799. true,
  42800. false
  42801. ],
  42802. "AFL-2.1": [
  42803. "Academic Free License v2.1",
  42804. true,
  42805. false
  42806. ],
  42807. "AFL-3.0": [
  42808. "Academic Free License v3.0",
  42809. true,
  42810. false
  42811. ],
  42812. "Afmparse": [
  42813. "Afmparse License",
  42814. false,
  42815. false
  42816. ],
  42817. "AGPL-1.0": [
  42818. "Affero General Public License v1.0",
  42819. false,
  42820. true
  42821. ],
  42822. "AGPL-1.0-only": [
  42823. "Affero General Public License v1.0 only",
  42824. false,
  42825. false
  42826. ],
  42827. "AGPL-1.0-or-later": [
  42828. "Affero General Public License v1.0 or later",
  42829. false,
  42830. false
  42831. ],
  42832. "AGPL-3.0": [
  42833. "GNU Affero General Public License v3.0",
  42834. true,
  42835. true
  42836. ],
  42837. "AGPL-3.0-only": [
  42838. "GNU Affero General Public License v3.0 only",
  42839. true,
  42840. false
  42841. ],
  42842. "AGPL-3.0-or-later": [
  42843. "GNU Affero General Public License v3.0 or later",
  42844. true,
  42845. false
  42846. ],
  42847. "Aladdin": [
  42848. "Aladdin Free Public License",
  42849. false,
  42850. false
  42851. ],
  42852. "AMDPLPA": [
  42853. "AMD's plpa_map.c License",
  42854. false,
  42855. false
  42856. ],
  42857. "AML": [
  42858. "Apple MIT License",
  42859. false,
  42860. false
  42861. ],
  42862. "AMPAS": [
  42863. "Academy of Motion Picture Arts and Sciences BSD",
  42864. false,
  42865. false
  42866. ],
  42867. "ANTLR-PD": [
  42868. "ANTLR Software Rights Notice",
  42869. false,
  42870. false
  42871. ],
  42872. "ANTLR-PD-fallback": [
  42873. "ANTLR Software Rights Notice with license fallback",
  42874. false,
  42875. false
  42876. ],
  42877. "Apache-1.0": [
  42878. "Apache License 1.0",
  42879. false,
  42880. false
  42881. ],
  42882. "Apache-1.1": [
  42883. "Apache License 1.1",
  42884. true,
  42885. false
  42886. ],
  42887. "Apache-2.0": [
  42888. "Apache License 2.0",
  42889. true,
  42890. false
  42891. ],
  42892. "APAFML": [
  42893. "Adobe Postscript AFM License",
  42894. false,
  42895. false
  42896. ],
  42897. "APL-1.0": [
  42898. "Adaptive Public License 1.0",
  42899. true,
  42900. false
  42901. ],
  42902. "APSL-1.0": [
  42903. "Apple Public Source License 1.0",
  42904. true,
  42905. false
  42906. ],
  42907. "APSL-1.1": [
  42908. "Apple Public Source License 1.1",
  42909. true,
  42910. false
  42911. ],
  42912. "APSL-1.2": [
  42913. "Apple Public Source License 1.2",
  42914. true,
  42915. false
  42916. ],
  42917. "APSL-2.0": [
  42918. "Apple Public Source License 2.0",
  42919. true,
  42920. false
  42921. ],
  42922. "Artistic-1.0": [
  42923. "Artistic License 1.0",
  42924. true,
  42925. false
  42926. ],
  42927. "Artistic-1.0-cl8": [
  42928. "Artistic License 1.0 w/clause 8",
  42929. true,
  42930. false
  42931. ],
  42932. "Artistic-1.0-Perl": [
  42933. "Artistic License 1.0 (Perl)",
  42934. true,
  42935. false
  42936. ],
  42937. "Artistic-2.0": [
  42938. "Artistic License 2.0",
  42939. true,
  42940. false
  42941. ],
  42942. "Bahyph": [
  42943. "Bahyph License",
  42944. false,
  42945. false
  42946. ],
  42947. "Barr": [
  42948. "Barr License",
  42949. false,
  42950. false
  42951. ],
  42952. "Beerware": [
  42953. "Beerware License",
  42954. false,
  42955. false
  42956. ],
  42957. "BitTorrent-1.0": [
  42958. "BitTorrent Open Source License v1.0",
  42959. false,
  42960. false
  42961. ],
  42962. "BitTorrent-1.1": [
  42963. "BitTorrent Open Source License v1.1",
  42964. false,
  42965. false
  42966. ],
  42967. "blessing": [
  42968. "SQLite Blessing",
  42969. false,
  42970. false
  42971. ],
  42972. "BlueOak-1.0.0": [
  42973. "Blue Oak Model License 1.0.0",
  42974. false,
  42975. false
  42976. ],
  42977. "Borceux": [
  42978. "Borceux license",
  42979. false,
  42980. false
  42981. ],
  42982. "BSD-1-Clause": [
  42983. "BSD 1-Clause License",
  42984. true,
  42985. false
  42986. ],
  42987. "BSD-2-Clause": [
  42988. "BSD 2-Clause \"Simplified\" License",
  42989. true,
  42990. false
  42991. ],
  42992. "BSD-2-Clause-FreeBSD": [
  42993. "BSD 2-Clause FreeBSD License",
  42994. false,
  42995. true
  42996. ],
  42997. "BSD-2-Clause-NetBSD": [
  42998. "BSD 2-Clause NetBSD License",
  42999. false,
  43000. true
  43001. ],
  43002. "BSD-2-Clause-Patent": [
  43003. "BSD-2-Clause Plus Patent License",
  43004. true,
  43005. false
  43006. ],
  43007. "BSD-2-Clause-Views": [
  43008. "BSD 2-Clause with views sentence",
  43009. false,
  43010. false
  43011. ],
  43012. "BSD-3-Clause": [
  43013. "BSD 3-Clause \"New\" or \"Revised\" License",
  43014. true,
  43015. false
  43016. ],
  43017. "BSD-3-Clause-Attribution": [
  43018. "BSD with attribution",
  43019. false,
  43020. false
  43021. ],
  43022. "BSD-3-Clause-Clear": [
  43023. "BSD 3-Clause Clear License",
  43024. false,
  43025. false
  43026. ],
  43027. "BSD-3-Clause-LBNL": [
  43028. "Lawrence Berkeley National Labs BSD variant license",
  43029. true,
  43030. false
  43031. ],
  43032. "BSD-3-Clause-Modification": [
  43033. "BSD 3-Clause Modification",
  43034. false,
  43035. false
  43036. ],
  43037. "BSD-3-Clause-No-Military-License": [
  43038. "BSD 3-Clause No Military License",
  43039. false,
  43040. false
  43041. ],
  43042. "BSD-3-Clause-No-Nuclear-License": [
  43043. "BSD 3-Clause No Nuclear License",
  43044. false,
  43045. false
  43046. ],
  43047. "BSD-3-Clause-No-Nuclear-License-2014": [
  43048. "BSD 3-Clause No Nuclear License 2014",
  43049. false,
  43050. false
  43051. ],
  43052. "BSD-3-Clause-No-Nuclear-Warranty": [
  43053. "BSD 3-Clause No Nuclear Warranty",
  43054. false,
  43055. false
  43056. ],
  43057. "BSD-3-Clause-Open-MPI": [
  43058. "BSD 3-Clause Open MPI variant",
  43059. false,
  43060. false
  43061. ],
  43062. "BSD-4-Clause": [
  43063. "BSD 4-Clause \"Original\" or \"Old\" License",
  43064. false,
  43065. false
  43066. ],
  43067. "BSD-4-Clause-Shortened": [
  43068. "BSD 4 Clause Shortened",
  43069. false,
  43070. false
  43071. ],
  43072. "BSD-4-Clause-UC": [
  43073. "BSD-4-Clause (University of California-Specific)",
  43074. false,
  43075. false
  43076. ],
  43077. "BSD-Protection": [
  43078. "BSD Protection License",
  43079. false,
  43080. false
  43081. ],
  43082. "BSD-Source-Code": [
  43083. "BSD Source Code Attribution",
  43084. false,
  43085. false
  43086. ],
  43087. "BSL-1.0": [
  43088. "Boost Software License 1.0",
  43089. true,
  43090. false
  43091. ],
  43092. "BUSL-1.1": [
  43093. "Business Source License 1.1",
  43094. false,
  43095. false
  43096. ],
  43097. "bzip2-1.0.5": [
  43098. "bzip2 and libbzip2 License v1.0.5",
  43099. false,
  43100. false
  43101. ],
  43102. "bzip2-1.0.6": [
  43103. "bzip2 and libbzip2 License v1.0.6",
  43104. false,
  43105. false
  43106. ],
  43107. "C-UDA-1.0": [
  43108. "Computational Use of Data Agreement v1.0",
  43109. false,
  43110. false
  43111. ],
  43112. "CAL-1.0": [
  43113. "Cryptographic Autonomy License 1.0",
  43114. true,
  43115. false
  43116. ],
  43117. "CAL-1.0-Combined-Work-Exception": [
  43118. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  43119. true,
  43120. false
  43121. ],
  43122. "Caldera": [
  43123. "Caldera License",
  43124. false,
  43125. false
  43126. ],
  43127. "CATOSL-1.1": [
  43128. "Computer Associates Trusted Open Source License 1.1",
  43129. true,
  43130. false
  43131. ],
  43132. "CC-BY-1.0": [
  43133. "Creative Commons Attribution 1.0 Generic",
  43134. false,
  43135. false
  43136. ],
  43137. "CC-BY-2.0": [
  43138. "Creative Commons Attribution 2.0 Generic",
  43139. false,
  43140. false
  43141. ],
  43142. "CC-BY-2.5": [
  43143. "Creative Commons Attribution 2.5 Generic",
  43144. false,
  43145. false
  43146. ],
  43147. "CC-BY-2.5-AU": [
  43148. "Creative Commons Attribution 2.5 Australia",
  43149. false,
  43150. false
  43151. ],
  43152. "CC-BY-3.0": [
  43153. "Creative Commons Attribution 3.0 Unported",
  43154. false,
  43155. false
  43156. ],
  43157. "CC-BY-3.0-AT": [
  43158. "Creative Commons Attribution 3.0 Austria",
  43159. false,
  43160. false
  43161. ],
  43162. "CC-BY-3.0-DE": [
  43163. "Creative Commons Attribution 3.0 Germany",
  43164. false,
  43165. false
  43166. ],
  43167. "CC-BY-3.0-NL": [
  43168. "Creative Commons Attribution 3.0 Netherlands",
  43169. false,
  43170. false
  43171. ],
  43172. "CC-BY-3.0-US": [
  43173. "Creative Commons Attribution 3.0 United States",
  43174. false,
  43175. false
  43176. ],
  43177. "CC-BY-4.0": [
  43178. "Creative Commons Attribution 4.0 International",
  43179. false,
  43180. false
  43181. ],
  43182. "CC-BY-NC-1.0": [
  43183. "Creative Commons Attribution Non Commercial 1.0 Generic",
  43184. false,
  43185. false
  43186. ],
  43187. "CC-BY-NC-2.0": [
  43188. "Creative Commons Attribution Non Commercial 2.0 Generic",
  43189. false,
  43190. false
  43191. ],
  43192. "CC-BY-NC-2.5": [
  43193. "Creative Commons Attribution Non Commercial 2.5 Generic",
  43194. false,
  43195. false
  43196. ],
  43197. "CC-BY-NC-3.0": [
  43198. "Creative Commons Attribution Non Commercial 3.0 Unported",
  43199. false,
  43200. false
  43201. ],
  43202. "CC-BY-NC-3.0-DE": [
  43203. "Creative Commons Attribution Non Commercial 3.0 Germany",
  43204. false,
  43205. false
  43206. ],
  43207. "CC-BY-NC-4.0": [
  43208. "Creative Commons Attribution Non Commercial 4.0 International",
  43209. false,
  43210. false
  43211. ],
  43212. "CC-BY-NC-ND-1.0": [
  43213. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  43214. false,
  43215. false
  43216. ],
  43217. "CC-BY-NC-ND-2.0": [
  43218. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  43219. false,
  43220. false
  43221. ],
  43222. "CC-BY-NC-ND-2.5": [
  43223. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  43224. false,
  43225. false
  43226. ],
  43227. "CC-BY-NC-ND-3.0": [
  43228. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  43229. false,
  43230. false
  43231. ],
  43232. "CC-BY-NC-ND-3.0-DE": [
  43233. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany",
  43234. false,
  43235. false
  43236. ],
  43237. "CC-BY-NC-ND-3.0-IGO": [
  43238. "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO",
  43239. false,
  43240. false
  43241. ],
  43242. "CC-BY-NC-ND-4.0": [
  43243. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  43244. false,
  43245. false
  43246. ],
  43247. "CC-BY-NC-SA-1.0": [
  43248. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  43249. false,
  43250. false
  43251. ],
  43252. "CC-BY-NC-SA-2.0": [
  43253. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  43254. false,
  43255. false
  43256. ],
  43257. "CC-BY-NC-SA-2.0-FR": [
  43258. "Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France",
  43259. false,
  43260. false
  43261. ],
  43262. "CC-BY-NC-SA-2.0-UK": [
  43263. "Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales",
  43264. false,
  43265. false
  43266. ],
  43267. "CC-BY-NC-SA-2.5": [
  43268. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  43269. false,
  43270. false
  43271. ],
  43272. "CC-BY-NC-SA-3.0": [
  43273. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  43274. false,
  43275. false
  43276. ],
  43277. "CC-BY-NC-SA-3.0-DE": [
  43278. "Creative Commons Attribution Non Commercial Share Alike 3.0 Germany",
  43279. false,
  43280. false
  43281. ],
  43282. "CC-BY-NC-SA-3.0-IGO": [
  43283. "Creative Commons Attribution Non Commercial Share Alike 3.0 IGO",
  43284. false,
  43285. false
  43286. ],
  43287. "CC-BY-NC-SA-4.0": [
  43288. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  43289. false,
  43290. false
  43291. ],
  43292. "CC-BY-ND-1.0": [
  43293. "Creative Commons Attribution No Derivatives 1.0 Generic",
  43294. false,
  43295. false
  43296. ],
  43297. "CC-BY-ND-2.0": [
  43298. "Creative Commons Attribution No Derivatives 2.0 Generic",
  43299. false,
  43300. false
  43301. ],
  43302. "CC-BY-ND-2.5": [
  43303. "Creative Commons Attribution No Derivatives 2.5 Generic",
  43304. false,
  43305. false
  43306. ],
  43307. "CC-BY-ND-3.0": [
  43308. "Creative Commons Attribution No Derivatives 3.0 Unported",
  43309. false,
  43310. false
  43311. ],
  43312. "CC-BY-ND-3.0-DE": [
  43313. "Creative Commons Attribution No Derivatives 3.0 Germany",
  43314. false,
  43315. false
  43316. ],
  43317. "CC-BY-ND-4.0": [
  43318. "Creative Commons Attribution No Derivatives 4.0 International",
  43319. false,
  43320. false
  43321. ],
  43322. "CC-BY-SA-1.0": [
  43323. "Creative Commons Attribution Share Alike 1.0 Generic",
  43324. false,
  43325. false
  43326. ],
  43327. "CC-BY-SA-2.0": [
  43328. "Creative Commons Attribution Share Alike 2.0 Generic",
  43329. false,
  43330. false
  43331. ],
  43332. "CC-BY-SA-2.0-UK": [
  43333. "Creative Commons Attribution Share Alike 2.0 England and Wales",
  43334. false,
  43335. false
  43336. ],
  43337. "CC-BY-SA-2.1-JP": [
  43338. "Creative Commons Attribution Share Alike 2.1 Japan",
  43339. false,
  43340. false
  43341. ],
  43342. "CC-BY-SA-2.5": [
  43343. "Creative Commons Attribution Share Alike 2.5 Generic",
  43344. false,
  43345. false
  43346. ],
  43347. "CC-BY-SA-3.0": [
  43348. "Creative Commons Attribution Share Alike 3.0 Unported",
  43349. false,
  43350. false
  43351. ],
  43352. "CC-BY-SA-3.0-AT": [
  43353. "Creative Commons Attribution Share Alike 3.0 Austria",
  43354. false,
  43355. false
  43356. ],
  43357. "CC-BY-SA-3.0-DE": [
  43358. "Creative Commons Attribution Share Alike 3.0 Germany",
  43359. false,
  43360. false
  43361. ],
  43362. "CC-BY-SA-4.0": [
  43363. "Creative Commons Attribution Share Alike 4.0 International",
  43364. false,
  43365. false
  43366. ],
  43367. "CC-PDDC": [
  43368. "Creative Commons Public Domain Dedication and Certification",
  43369. false,
  43370. false
  43371. ],
  43372. "CC0-1.0": [
  43373. "Creative Commons Zero v1.0 Universal",
  43374. false,
  43375. false
  43376. ],
  43377. "CDDL-1.0": [
  43378. "Common Development and Distribution License 1.0",
  43379. true,
  43380. false
  43381. ],
  43382. "CDDL-1.1": [
  43383. "Common Development and Distribution License 1.1",
  43384. false,
  43385. false
  43386. ],
  43387. "CDL-1.0": [
  43388. "Common Documentation License 1.0",
  43389. false,
  43390. false
  43391. ],
  43392. "CDLA-Permissive-1.0": [
  43393. "Community Data License Agreement Permissive 1.0",
  43394. false,
  43395. false
  43396. ],
  43397. "CDLA-Permissive-2.0": [
  43398. "Community Data License Agreement Permissive 2.0",
  43399. false,
  43400. false
  43401. ],
  43402. "CDLA-Sharing-1.0": [
  43403. "Community Data License Agreement Sharing 1.0",
  43404. false,
  43405. false
  43406. ],
  43407. "CECILL-1.0": [
  43408. "CeCILL Free Software License Agreement v1.0",
  43409. false,
  43410. false
  43411. ],
  43412. "CECILL-1.1": [
  43413. "CeCILL Free Software License Agreement v1.1",
  43414. false,
  43415. false
  43416. ],
  43417. "CECILL-2.0": [
  43418. "CeCILL Free Software License Agreement v2.0",
  43419. false,
  43420. false
  43421. ],
  43422. "CECILL-2.1": [
  43423. "CeCILL Free Software License Agreement v2.1",
  43424. true,
  43425. false
  43426. ],
  43427. "CECILL-B": [
  43428. "CeCILL-B Free Software License Agreement",
  43429. false,
  43430. false
  43431. ],
  43432. "CECILL-C": [
  43433. "CeCILL-C Free Software License Agreement",
  43434. false,
  43435. false
  43436. ],
  43437. "CERN-OHL-1.1": [
  43438. "CERN Open Hardware Licence v1.1",
  43439. false,
  43440. false
  43441. ],
  43442. "CERN-OHL-1.2": [
  43443. "CERN Open Hardware Licence v1.2",
  43444. false,
  43445. false
  43446. ],
  43447. "CERN-OHL-P-2.0": [
  43448. "CERN Open Hardware Licence Version 2 - Permissive",
  43449. true,
  43450. false
  43451. ],
  43452. "CERN-OHL-S-2.0": [
  43453. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  43454. true,
  43455. false
  43456. ],
  43457. "CERN-OHL-W-2.0": [
  43458. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  43459. true,
  43460. false
  43461. ],
  43462. "ClArtistic": [
  43463. "Clarified Artistic License",
  43464. false,
  43465. false
  43466. ],
  43467. "CNRI-Jython": [
  43468. "CNRI Jython License",
  43469. false,
  43470. false
  43471. ],
  43472. "CNRI-Python": [
  43473. "CNRI Python License",
  43474. true,
  43475. false
  43476. ],
  43477. "CNRI-Python-GPL-Compatible": [
  43478. "CNRI Python Open Source GPL Compatible License Agreement",
  43479. false,
  43480. false
  43481. ],
  43482. "COIL-1.0": [
  43483. "Copyfree Open Innovation License",
  43484. false,
  43485. false
  43486. ],
  43487. "Community-Spec-1.0": [
  43488. "Community Specification License 1.0",
  43489. false,
  43490. false
  43491. ],
  43492. "Condor-1.1": [
  43493. "Condor Public License v1.1",
  43494. false,
  43495. false
  43496. ],
  43497. "copyleft-next-0.3.0": [
  43498. "copyleft-next 0.3.0",
  43499. false,
  43500. false
  43501. ],
  43502. "copyleft-next-0.3.1": [
  43503. "copyleft-next 0.3.1",
  43504. false,
  43505. false
  43506. ],
  43507. "CPAL-1.0": [
  43508. "Common Public Attribution License 1.0",
  43509. true,
  43510. false
  43511. ],
  43512. "CPL-1.0": [
  43513. "Common Public License 1.0",
  43514. true,
  43515. false
  43516. ],
  43517. "CPOL-1.02": [
  43518. "Code Project Open License 1.02",
  43519. false,
  43520. false
  43521. ],
  43522. "Crossword": [
  43523. "Crossword License",
  43524. false,
  43525. false
  43526. ],
  43527. "CrystalStacker": [
  43528. "CrystalStacker License",
  43529. false,
  43530. false
  43531. ],
  43532. "CUA-OPL-1.0": [
  43533. "CUA Office Public License v1.0",
  43534. true,
  43535. false
  43536. ],
  43537. "Cube": [
  43538. "Cube License",
  43539. false,
  43540. false
  43541. ],
  43542. "curl": [
  43543. "curl License",
  43544. false,
  43545. false
  43546. ],
  43547. "D-FSL-1.0": [
  43548. "Deutsche Freie Software Lizenz",
  43549. false,
  43550. false
  43551. ],
  43552. "diffmark": [
  43553. "diffmark license",
  43554. false,
  43555. false
  43556. ],
  43557. "DOC": [
  43558. "DOC License",
  43559. false,
  43560. false
  43561. ],
  43562. "Dotseqn": [
  43563. "Dotseqn License",
  43564. false,
  43565. false
  43566. ],
  43567. "DRL-1.0": [
  43568. "Detection Rule License 1.0",
  43569. false,
  43570. false
  43571. ],
  43572. "DSDP": [
  43573. "DSDP License",
  43574. false,
  43575. false
  43576. ],
  43577. "dvipdfm": [
  43578. "dvipdfm License",
  43579. false,
  43580. false
  43581. ],
  43582. "ECL-1.0": [
  43583. "Educational Community License v1.0",
  43584. true,
  43585. false
  43586. ],
  43587. "ECL-2.0": [
  43588. "Educational Community License v2.0",
  43589. true,
  43590. false
  43591. ],
  43592. "eCos-2.0": [
  43593. "eCos license version 2.0",
  43594. false,
  43595. true
  43596. ],
  43597. "EFL-1.0": [
  43598. "Eiffel Forum License v1.0",
  43599. true,
  43600. false
  43601. ],
  43602. "EFL-2.0": [
  43603. "Eiffel Forum License v2.0",
  43604. true,
  43605. false
  43606. ],
  43607. "eGenix": [
  43608. "eGenix.com Public License 1.1.0",
  43609. false,
  43610. false
  43611. ],
  43612. "Entessa": [
  43613. "Entessa Public License v1.0",
  43614. true,
  43615. false
  43616. ],
  43617. "EPICS": [
  43618. "EPICS Open License",
  43619. false,
  43620. false
  43621. ],
  43622. "EPL-1.0": [
  43623. "Eclipse Public License 1.0",
  43624. true,
  43625. false
  43626. ],
  43627. "EPL-2.0": [
  43628. "Eclipse Public License 2.0",
  43629. true,
  43630. false
  43631. ],
  43632. "ErlPL-1.1": [
  43633. "Erlang Public License v1.1",
  43634. false,
  43635. false
  43636. ],
  43637. "etalab-2.0": [
  43638. "Etalab Open License 2.0",
  43639. false,
  43640. false
  43641. ],
  43642. "EUDatagrid": [
  43643. "EU DataGrid Software License",
  43644. true,
  43645. false
  43646. ],
  43647. "EUPL-1.0": [
  43648. "European Union Public License 1.0",
  43649. false,
  43650. false
  43651. ],
  43652. "EUPL-1.1": [
  43653. "European Union Public License 1.1",
  43654. true,
  43655. false
  43656. ],
  43657. "EUPL-1.2": [
  43658. "European Union Public License 1.2",
  43659. true,
  43660. false
  43661. ],
  43662. "Eurosym": [
  43663. "Eurosym License",
  43664. false,
  43665. false
  43666. ],
  43667. "Fair": [
  43668. "Fair License",
  43669. true,
  43670. false
  43671. ],
  43672. "FDK-AAC": [
  43673. "Fraunhofer FDK AAC Codec Library",
  43674. false,
  43675. false
  43676. ],
  43677. "Frameworx-1.0": [
  43678. "Frameworx Open License 1.0",
  43679. true,
  43680. false
  43681. ],
  43682. "FreeBSD-DOC": [
  43683. "FreeBSD Documentation License",
  43684. false,
  43685. false
  43686. ],
  43687. "FreeImage": [
  43688. "FreeImage Public License v1.0",
  43689. false,
  43690. false
  43691. ],
  43692. "FSFAP": [
  43693. "FSF All Permissive License",
  43694. false,
  43695. false
  43696. ],
  43697. "FSFUL": [
  43698. "FSF Unlimited License",
  43699. false,
  43700. false
  43701. ],
  43702. "FSFULLR": [
  43703. "FSF Unlimited License (with License Retention)",
  43704. false,
  43705. false
  43706. ],
  43707. "FTL": [
  43708. "Freetype Project License",
  43709. false,
  43710. false
  43711. ],
  43712. "GD": [
  43713. "GD License",
  43714. false,
  43715. false
  43716. ],
  43717. "GFDL-1.1": [
  43718. "GNU Free Documentation License v1.1",
  43719. false,
  43720. true
  43721. ],
  43722. "GFDL-1.1-invariants-only": [
  43723. "GNU Free Documentation License v1.1 only - invariants",
  43724. false,
  43725. false
  43726. ],
  43727. "GFDL-1.1-invariants-or-later": [
  43728. "GNU Free Documentation License v1.1 or later - invariants",
  43729. false,
  43730. false
  43731. ],
  43732. "GFDL-1.1-no-invariants-only": [
  43733. "GNU Free Documentation License v1.1 only - no invariants",
  43734. false,
  43735. false
  43736. ],
  43737. "GFDL-1.1-no-invariants-or-later": [
  43738. "GNU Free Documentation License v1.1 or later - no invariants",
  43739. false,
  43740. false
  43741. ],
  43742. "GFDL-1.1-only": [
  43743. "GNU Free Documentation License v1.1 only",
  43744. false,
  43745. false
  43746. ],
  43747. "GFDL-1.1-or-later": [
  43748. "GNU Free Documentation License v1.1 or later",
  43749. false,
  43750. false
  43751. ],
  43752. "GFDL-1.2": [
  43753. "GNU Free Documentation License v1.2",
  43754. false,
  43755. true
  43756. ],
  43757. "GFDL-1.2-invariants-only": [
  43758. "GNU Free Documentation License v1.2 only - invariants",
  43759. false,
  43760. false
  43761. ],
  43762. "GFDL-1.2-invariants-or-later": [
  43763. "GNU Free Documentation License v1.2 or later - invariants",
  43764. false,
  43765. false
  43766. ],
  43767. "GFDL-1.2-no-invariants-only": [
  43768. "GNU Free Documentation License v1.2 only - no invariants",
  43769. false,
  43770. false
  43771. ],
  43772. "GFDL-1.2-no-invariants-or-later": [
  43773. "GNU Free Documentation License v1.2 or later - no invariants",
  43774. false,
  43775. false
  43776. ],
  43777. "GFDL-1.2-only": [
  43778. "GNU Free Documentation License v1.2 only",
  43779. false,
  43780. false
  43781. ],
  43782. "GFDL-1.2-or-later": [
  43783. "GNU Free Documentation License v1.2 or later",
  43784. false,
  43785. false
  43786. ],
  43787. "GFDL-1.3": [
  43788. "GNU Free Documentation License v1.3",
  43789. false,
  43790. true
  43791. ],
  43792. "GFDL-1.3-invariants-only": [
  43793. "GNU Free Documentation License v1.3 only - invariants",
  43794. false,
  43795. false
  43796. ],
  43797. "GFDL-1.3-invariants-or-later": [
  43798. "GNU Free Documentation License v1.3 or later - invariants",
  43799. false,
  43800. false
  43801. ],
  43802. "GFDL-1.3-no-invariants-only": [
  43803. "GNU Free Documentation License v1.3 only - no invariants",
  43804. false,
  43805. false
  43806. ],
  43807. "GFDL-1.3-no-invariants-or-later": [
  43808. "GNU Free Documentation License v1.3 or later - no invariants",
  43809. false,
  43810. false
  43811. ],
  43812. "GFDL-1.3-only": [
  43813. "GNU Free Documentation License v1.3 only",
  43814. false,
  43815. false
  43816. ],
  43817. "GFDL-1.3-or-later": [
  43818. "GNU Free Documentation License v1.3 or later",
  43819. false,
  43820. false
  43821. ],
  43822. "Giftware": [
  43823. "Giftware License",
  43824. false,
  43825. false
  43826. ],
  43827. "GL2PS": [
  43828. "GL2PS License",
  43829. false,
  43830. false
  43831. ],
  43832. "Glide": [
  43833. "3dfx Glide License",
  43834. false,
  43835. false
  43836. ],
  43837. "Glulxe": [
  43838. "Glulxe License",
  43839. false,
  43840. false
  43841. ],
  43842. "GLWTPL": [
  43843. "Good Luck With That Public License",
  43844. false,
  43845. false
  43846. ],
  43847. "gnuplot": [
  43848. "gnuplot License",
  43849. false,
  43850. false
  43851. ],
  43852. "GPL-1.0": [
  43853. "GNU General Public License v1.0 only",
  43854. false,
  43855. true
  43856. ],
  43857. "GPL-1.0+": [
  43858. "GNU General Public License v1.0 or later",
  43859. false,
  43860. true
  43861. ],
  43862. "GPL-1.0-only": [
  43863. "GNU General Public License v1.0 only",
  43864. false,
  43865. false
  43866. ],
  43867. "GPL-1.0-or-later": [
  43868. "GNU General Public License v1.0 or later",
  43869. false,
  43870. false
  43871. ],
  43872. "GPL-2.0": [
  43873. "GNU General Public License v2.0 only",
  43874. true,
  43875. true
  43876. ],
  43877. "GPL-2.0+": [
  43878. "GNU General Public License v2.0 or later",
  43879. true,
  43880. true
  43881. ],
  43882. "GPL-2.0-only": [
  43883. "GNU General Public License v2.0 only",
  43884. true,
  43885. false
  43886. ],
  43887. "GPL-2.0-or-later": [
  43888. "GNU General Public License v2.0 or later",
  43889. true,
  43890. false
  43891. ],
  43892. "GPL-2.0-with-autoconf-exception": [
  43893. "GNU General Public License v2.0 w/Autoconf exception",
  43894. false,
  43895. true
  43896. ],
  43897. "GPL-2.0-with-bison-exception": [
  43898. "GNU General Public License v2.0 w/Bison exception",
  43899. false,
  43900. true
  43901. ],
  43902. "GPL-2.0-with-classpath-exception": [
  43903. "GNU General Public License v2.0 w/Classpath exception",
  43904. false,
  43905. true
  43906. ],
  43907. "GPL-2.0-with-font-exception": [
  43908. "GNU General Public License v2.0 w/Font exception",
  43909. false,
  43910. true
  43911. ],
  43912. "GPL-2.0-with-GCC-exception": [
  43913. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  43914. false,
  43915. true
  43916. ],
  43917. "GPL-3.0": [
  43918. "GNU General Public License v3.0 only",
  43919. true,
  43920. true
  43921. ],
  43922. "GPL-3.0+": [
  43923. "GNU General Public License v3.0 or later",
  43924. true,
  43925. true
  43926. ],
  43927. "GPL-3.0-only": [
  43928. "GNU General Public License v3.0 only",
  43929. true,
  43930. false
  43931. ],
  43932. "GPL-3.0-or-later": [
  43933. "GNU General Public License v3.0 or later",
  43934. true,
  43935. false
  43936. ],
  43937. "GPL-3.0-with-autoconf-exception": [
  43938. "GNU General Public License v3.0 w/Autoconf exception",
  43939. false,
  43940. true
  43941. ],
  43942. "GPL-3.0-with-GCC-exception": [
  43943. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  43944. true,
  43945. true
  43946. ],
  43947. "gSOAP-1.3b": [
  43948. "gSOAP Public License v1.3b",
  43949. false,
  43950. false
  43951. ],
  43952. "HaskellReport": [
  43953. "Haskell Language Report License",
  43954. false,
  43955. false
  43956. ],
  43957. "Hippocratic-2.1": [
  43958. "Hippocratic License 2.1",
  43959. false,
  43960. false
  43961. ],
  43962. "HPND": [
  43963. "Historical Permission Notice and Disclaimer",
  43964. true,
  43965. false
  43966. ],
  43967. "HPND-sell-variant": [
  43968. "Historical Permission Notice and Disclaimer - sell variant",
  43969. false,
  43970. false
  43971. ],
  43972. "HTMLTIDY": [
  43973. "HTML Tidy License",
  43974. false,
  43975. false
  43976. ],
  43977. "IBM-pibs": [
  43978. "IBM PowerPC Initialization and Boot Software",
  43979. false,
  43980. false
  43981. ],
  43982. "ICU": [
  43983. "ICU License",
  43984. false,
  43985. false
  43986. ],
  43987. "IJG": [
  43988. "Independent JPEG Group License",
  43989. false,
  43990. false
  43991. ],
  43992. "ImageMagick": [
  43993. "ImageMagick License",
  43994. false,
  43995. false
  43996. ],
  43997. "iMatix": [
  43998. "iMatix Standard Function Library Agreement",
  43999. false,
  44000. false
  44001. ],
  44002. "Imlib2": [
  44003. "Imlib2 License",
  44004. false,
  44005. false
  44006. ],
  44007. "Info-ZIP": [
  44008. "Info-ZIP License",
  44009. false,
  44010. false
  44011. ],
  44012. "Intel": [
  44013. "Intel Open Source License",
  44014. true,
  44015. false
  44016. ],
  44017. "Intel-ACPI": [
  44018. "Intel ACPI Software License Agreement",
  44019. false,
  44020. false
  44021. ],
  44022. "Interbase-1.0": [
  44023. "Interbase Public License v1.0",
  44024. false,
  44025. false
  44026. ],
  44027. "IPA": [
  44028. "IPA Font License",
  44029. true,
  44030. false
  44031. ],
  44032. "IPL-1.0": [
  44033. "IBM Public License v1.0",
  44034. true,
  44035. false
  44036. ],
  44037. "ISC": [
  44038. "ISC License",
  44039. true,
  44040. false
  44041. ],
  44042. "JasPer-2.0": [
  44043. "JasPer License",
  44044. false,
  44045. false
  44046. ],
  44047. "JPNIC": [
  44048. "Japan Network Information Center License",
  44049. false,
  44050. false
  44051. ],
  44052. "JSON": [
  44053. "JSON License",
  44054. false,
  44055. false
  44056. ],
  44057. "LAL-1.2": [
  44058. "Licence Art Libre 1.2",
  44059. false,
  44060. false
  44061. ],
  44062. "LAL-1.3": [
  44063. "Licence Art Libre 1.3",
  44064. false,
  44065. false
  44066. ],
  44067. "Latex2e": [
  44068. "Latex2e License",
  44069. false,
  44070. false
  44071. ],
  44072. "Leptonica": [
  44073. "Leptonica License",
  44074. false,
  44075. false
  44076. ],
  44077. "LGPL-2.0": [
  44078. "GNU Library General Public License v2 only",
  44079. true,
  44080. true
  44081. ],
  44082. "LGPL-2.0+": [
  44083. "GNU Library General Public License v2 or later",
  44084. true,
  44085. true
  44086. ],
  44087. "LGPL-2.0-only": [
  44088. "GNU Library General Public License v2 only",
  44089. true,
  44090. false
  44091. ],
  44092. "LGPL-2.0-or-later": [
  44093. "GNU Library General Public License v2 or later",
  44094. true,
  44095. false
  44096. ],
  44097. "LGPL-2.1": [
  44098. "GNU Lesser General Public License v2.1 only",
  44099. true,
  44100. true
  44101. ],
  44102. "LGPL-2.1+": [
  44103. "GNU Library General Public License v2.1 or later",
  44104. true,
  44105. true
  44106. ],
  44107. "LGPL-2.1-only": [
  44108. "GNU Lesser General Public License v2.1 only",
  44109. true,
  44110. false
  44111. ],
  44112. "LGPL-2.1-or-later": [
  44113. "GNU Lesser General Public License v2.1 or later",
  44114. true,
  44115. false
  44116. ],
  44117. "LGPL-3.0": [
  44118. "GNU Lesser General Public License v3.0 only",
  44119. true,
  44120. true
  44121. ],
  44122. "LGPL-3.0+": [
  44123. "GNU Lesser General Public License v3.0 or later",
  44124. true,
  44125. true
  44126. ],
  44127. "LGPL-3.0-only": [
  44128. "GNU Lesser General Public License v3.0 only",
  44129. true,
  44130. false
  44131. ],
  44132. "LGPL-3.0-or-later": [
  44133. "GNU Lesser General Public License v3.0 or later",
  44134. true,
  44135. false
  44136. ],
  44137. "LGPLLR": [
  44138. "Lesser General Public License For Linguistic Resources",
  44139. false,
  44140. false
  44141. ],
  44142. "Libpng": [
  44143. "libpng License",
  44144. false,
  44145. false
  44146. ],
  44147. "libpng-2.0": [
  44148. "PNG Reference Library version 2",
  44149. false,
  44150. false
  44151. ],
  44152. "libselinux-1.0": [
  44153. "libselinux public domain notice",
  44154. false,
  44155. false
  44156. ],
  44157. "libtiff": [
  44158. "libtiff License",
  44159. false,
  44160. false
  44161. ],
  44162. "LiLiQ-P-1.1": [
  44163. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  44164. true,
  44165. false
  44166. ],
  44167. "LiLiQ-R-1.1": [
  44168. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  44169. true,
  44170. false
  44171. ],
  44172. "LiLiQ-Rplus-1.1": [
  44173. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  44174. true,
  44175. false
  44176. ],
  44177. "Linux-man-pages-copyleft": [
  44178. "Linux man-pages Copyleft",
  44179. false,
  44180. false
  44181. ],
  44182. "Linux-OpenIB": [
  44183. "Linux Kernel Variant of OpenIB.org license",
  44184. false,
  44185. false
  44186. ],
  44187. "LPL-1.0": [
  44188. "Lucent Public License Version 1.0",
  44189. true,
  44190. false
  44191. ],
  44192. "LPL-1.02": [
  44193. "Lucent Public License v1.02",
  44194. true,
  44195. false
  44196. ],
  44197. "LPPL-1.0": [
  44198. "LaTeX Project Public License v1.0",
  44199. false,
  44200. false
  44201. ],
  44202. "LPPL-1.1": [
  44203. "LaTeX Project Public License v1.1",
  44204. false,
  44205. false
  44206. ],
  44207. "LPPL-1.2": [
  44208. "LaTeX Project Public License v1.2",
  44209. false,
  44210. false
  44211. ],
  44212. "LPPL-1.3a": [
  44213. "LaTeX Project Public License v1.3a",
  44214. false,
  44215. false
  44216. ],
  44217. "LPPL-1.3c": [
  44218. "LaTeX Project Public License v1.3c",
  44219. true,
  44220. false
  44221. ],
  44222. "MakeIndex": [
  44223. "MakeIndex License",
  44224. false,
  44225. false
  44226. ],
  44227. "MirOS": [
  44228. "The MirOS Licence",
  44229. true,
  44230. false
  44231. ],
  44232. "MIT": [
  44233. "MIT License",
  44234. true,
  44235. false
  44236. ],
  44237. "MIT-0": [
  44238. "MIT No Attribution",
  44239. true,
  44240. false
  44241. ],
  44242. "MIT-advertising": [
  44243. "Enlightenment License (e16)",
  44244. false,
  44245. false
  44246. ],
  44247. "MIT-CMU": [
  44248. "CMU License",
  44249. false,
  44250. false
  44251. ],
  44252. "MIT-enna": [
  44253. "enna License",
  44254. false,
  44255. false
  44256. ],
  44257. "MIT-feh": [
  44258. "feh License",
  44259. false,
  44260. false
  44261. ],
  44262. "MIT-Modern-Variant": [
  44263. "MIT License Modern Variant",
  44264. true,
  44265. false
  44266. ],
  44267. "MIT-open-group": [
  44268. "MIT Open Group variant",
  44269. false,
  44270. false
  44271. ],
  44272. "MITNFA": [
  44273. "MIT +no-false-attribs license",
  44274. false,
  44275. false
  44276. ],
  44277. "Motosoto": [
  44278. "Motosoto License",
  44279. true,
  44280. false
  44281. ],
  44282. "mpich2": [
  44283. "mpich2 License",
  44284. false,
  44285. false
  44286. ],
  44287. "MPL-1.0": [
  44288. "Mozilla Public License 1.0",
  44289. true,
  44290. false
  44291. ],
  44292. "MPL-1.1": [
  44293. "Mozilla Public License 1.1",
  44294. true,
  44295. false
  44296. ],
  44297. "MPL-2.0": [
  44298. "Mozilla Public License 2.0",
  44299. true,
  44300. false
  44301. ],
  44302. "MPL-2.0-no-copyleft-exception": [
  44303. "Mozilla Public License 2.0 (no copyleft exception)",
  44304. true,
  44305. false
  44306. ],
  44307. "MS-PL": [
  44308. "Microsoft Public License",
  44309. true,
  44310. false
  44311. ],
  44312. "MS-RL": [
  44313. "Microsoft Reciprocal License",
  44314. true,
  44315. false
  44316. ],
  44317. "MTLL": [
  44318. "Matrix Template Library License",
  44319. false,
  44320. false
  44321. ],
  44322. "MulanPSL-1.0": [
  44323. "Mulan Permissive Software License, Version 1",
  44324. false,
  44325. false
  44326. ],
  44327. "MulanPSL-2.0": [
  44328. "Mulan Permissive Software License, Version 2",
  44329. true,
  44330. false
  44331. ],
  44332. "Multics": [
  44333. "Multics License",
  44334. true,
  44335. false
  44336. ],
  44337. "Mup": [
  44338. "Mup License",
  44339. false,
  44340. false
  44341. ],
  44342. "NAIST-2003": [
  44343. "Nara Institute of Science and Technology License (2003)",
  44344. false,
  44345. false
  44346. ],
  44347. "NASA-1.3": [
  44348. "NASA Open Source Agreement 1.3",
  44349. true,
  44350. false
  44351. ],
  44352. "Naumen": [
  44353. "Naumen Public License",
  44354. true,
  44355. false
  44356. ],
  44357. "NBPL-1.0": [
  44358. "Net Boolean Public License v1",
  44359. false,
  44360. false
  44361. ],
  44362. "NCGL-UK-2.0": [
  44363. "Non-Commercial Government Licence",
  44364. false,
  44365. false
  44366. ],
  44367. "NCSA": [
  44368. "University of Illinois/NCSA Open Source License",
  44369. true,
  44370. false
  44371. ],
  44372. "Net-SNMP": [
  44373. "Net-SNMP License",
  44374. false,
  44375. false
  44376. ],
  44377. "NetCDF": [
  44378. "NetCDF license",
  44379. false,
  44380. false
  44381. ],
  44382. "Newsletr": [
  44383. "Newsletr License",
  44384. false,
  44385. false
  44386. ],
  44387. "NGPL": [
  44388. "Nethack General Public License",
  44389. true,
  44390. false
  44391. ],
  44392. "NIST-PD": [
  44393. "NIST Public Domain Notice",
  44394. false,
  44395. false
  44396. ],
  44397. "NIST-PD-fallback": [
  44398. "NIST Public Domain Notice with license fallback",
  44399. false,
  44400. false
  44401. ],
  44402. "NLOD-1.0": [
  44403. "Norwegian Licence for Open Government Data (NLOD) 1.0",
  44404. false,
  44405. false
  44406. ],
  44407. "NLOD-2.0": [
  44408. "Norwegian Licence for Open Government Data (NLOD) 2.0",
  44409. false,
  44410. false
  44411. ],
  44412. "NLPL": [
  44413. "No Limit Public License",
  44414. false,
  44415. false
  44416. ],
  44417. "Nokia": [
  44418. "Nokia Open Source License",
  44419. true,
  44420. false
  44421. ],
  44422. "NOSL": [
  44423. "Netizen Open Source License",
  44424. false,
  44425. false
  44426. ],
  44427. "Noweb": [
  44428. "Noweb License",
  44429. false,
  44430. false
  44431. ],
  44432. "NPL-1.0": [
  44433. "Netscape Public License v1.0",
  44434. false,
  44435. false
  44436. ],
  44437. "NPL-1.1": [
  44438. "Netscape Public License v1.1",
  44439. false,
  44440. false
  44441. ],
  44442. "NPOSL-3.0": [
  44443. "Non-Profit Open Software License 3.0",
  44444. true,
  44445. false
  44446. ],
  44447. "NRL": [
  44448. "NRL License",
  44449. false,
  44450. false
  44451. ],
  44452. "NTP": [
  44453. "NTP License",
  44454. true,
  44455. false
  44456. ],
  44457. "NTP-0": [
  44458. "NTP No Attribution",
  44459. false,
  44460. false
  44461. ],
  44462. "Nunit": [
  44463. "Nunit License",
  44464. false,
  44465. true
  44466. ],
  44467. "O-UDA-1.0": [
  44468. "Open Use of Data Agreement v1.0",
  44469. false,
  44470. false
  44471. ],
  44472. "OCCT-PL": [
  44473. "Open CASCADE Technology Public License",
  44474. false,
  44475. false
  44476. ],
  44477. "OCLC-2.0": [
  44478. "OCLC Research Public License 2.0",
  44479. true,
  44480. false
  44481. ],
  44482. "ODbL-1.0": [
  44483. "Open Data Commons Open Database License v1.0",
  44484. false,
  44485. false
  44486. ],
  44487. "ODC-By-1.0": [
  44488. "Open Data Commons Attribution License v1.0",
  44489. false,
  44490. false
  44491. ],
  44492. "OFL-1.0": [
  44493. "SIL Open Font License 1.0",
  44494. false,
  44495. false
  44496. ],
  44497. "OFL-1.0-no-RFN": [
  44498. "SIL Open Font License 1.0 with no Reserved Font Name",
  44499. false,
  44500. false
  44501. ],
  44502. "OFL-1.0-RFN": [
  44503. "SIL Open Font License 1.0 with Reserved Font Name",
  44504. false,
  44505. false
  44506. ],
  44507. "OFL-1.1": [
  44508. "SIL Open Font License 1.1",
  44509. true,
  44510. false
  44511. ],
  44512. "OFL-1.1-no-RFN": [
  44513. "SIL Open Font License 1.1 with no Reserved Font Name",
  44514. true,
  44515. false
  44516. ],
  44517. "OFL-1.1-RFN": [
  44518. "SIL Open Font License 1.1 with Reserved Font Name",
  44519. true,
  44520. false
  44521. ],
  44522. "OGC-1.0": [
  44523. "OGC Software License, Version 1.0",
  44524. false,
  44525. false
  44526. ],
  44527. "OGDL-Taiwan-1.0": [
  44528. "Taiwan Open Government Data License, version 1.0",
  44529. false,
  44530. false
  44531. ],
  44532. "OGL-Canada-2.0": [
  44533. "Open Government Licence - Canada",
  44534. false,
  44535. false
  44536. ],
  44537. "OGL-UK-1.0": [
  44538. "Open Government Licence v1.0",
  44539. false,
  44540. false
  44541. ],
  44542. "OGL-UK-2.0": [
  44543. "Open Government Licence v2.0",
  44544. false,
  44545. false
  44546. ],
  44547. "OGL-UK-3.0": [
  44548. "Open Government Licence v3.0",
  44549. false,
  44550. false
  44551. ],
  44552. "OGTSL": [
  44553. "Open Group Test Suite License",
  44554. true,
  44555. false
  44556. ],
  44557. "OLDAP-1.1": [
  44558. "Open LDAP Public License v1.1",
  44559. false,
  44560. false
  44561. ],
  44562. "OLDAP-1.2": [
  44563. "Open LDAP Public License v1.2",
  44564. false,
  44565. false
  44566. ],
  44567. "OLDAP-1.3": [
  44568. "Open LDAP Public License v1.3",
  44569. false,
  44570. false
  44571. ],
  44572. "OLDAP-1.4": [
  44573. "Open LDAP Public License v1.4",
  44574. false,
  44575. false
  44576. ],
  44577. "OLDAP-2.0": [
  44578. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  44579. false,
  44580. false
  44581. ],
  44582. "OLDAP-2.0.1": [
  44583. "Open LDAP Public License v2.0.1",
  44584. false,
  44585. false
  44586. ],
  44587. "OLDAP-2.1": [
  44588. "Open LDAP Public License v2.1",
  44589. false,
  44590. false
  44591. ],
  44592. "OLDAP-2.2": [
  44593. "Open LDAP Public License v2.2",
  44594. false,
  44595. false
  44596. ],
  44597. "OLDAP-2.2.1": [
  44598. "Open LDAP Public License v2.2.1",
  44599. false,
  44600. false
  44601. ],
  44602. "OLDAP-2.2.2": [
  44603. "Open LDAP Public License 2.2.2",
  44604. false,
  44605. false
  44606. ],
  44607. "OLDAP-2.3": [
  44608. "Open LDAP Public License v2.3",
  44609. false,
  44610. false
  44611. ],
  44612. "OLDAP-2.4": [
  44613. "Open LDAP Public License v2.4",
  44614. false,
  44615. false
  44616. ],
  44617. "OLDAP-2.5": [
  44618. "Open LDAP Public License v2.5",
  44619. false,
  44620. false
  44621. ],
  44622. "OLDAP-2.6": [
  44623. "Open LDAP Public License v2.6",
  44624. false,
  44625. false
  44626. ],
  44627. "OLDAP-2.7": [
  44628. "Open LDAP Public License v2.7",
  44629. false,
  44630. false
  44631. ],
  44632. "OLDAP-2.8": [
  44633. "Open LDAP Public License v2.8",
  44634. true,
  44635. false
  44636. ],
  44637. "OML": [
  44638. "Open Market License",
  44639. false,
  44640. false
  44641. ],
  44642. "OpenSSL": [
  44643. "OpenSSL License",
  44644. false,
  44645. false
  44646. ],
  44647. "OPL-1.0": [
  44648. "Open Public License v1.0",
  44649. false,
  44650. false
  44651. ],
  44652. "OPUBL-1.0": [
  44653. "Open Publication License v1.0",
  44654. false,
  44655. false
  44656. ],
  44657. "OSET-PL-2.1": [
  44658. "OSET Public License version 2.1",
  44659. true,
  44660. false
  44661. ],
  44662. "OSL-1.0": [
  44663. "Open Software License 1.0",
  44664. true,
  44665. false
  44666. ],
  44667. "OSL-1.1": [
  44668. "Open Software License 1.1",
  44669. false,
  44670. false
  44671. ],
  44672. "OSL-2.0": [
  44673. "Open Software License 2.0",
  44674. true,
  44675. false
  44676. ],
  44677. "OSL-2.1": [
  44678. "Open Software License 2.1",
  44679. true,
  44680. false
  44681. ],
  44682. "OSL-3.0": [
  44683. "Open Software License 3.0",
  44684. true,
  44685. false
  44686. ],
  44687. "Parity-6.0.0": [
  44688. "The Parity Public License 6.0.0",
  44689. false,
  44690. false
  44691. ],
  44692. "Parity-7.0.0": [
  44693. "The Parity Public License 7.0.0",
  44694. false,
  44695. false
  44696. ],
  44697. "PDDL-1.0": [
  44698. "Open Data Commons Public Domain Dedication & License 1.0",
  44699. false,
  44700. false
  44701. ],
  44702. "PHP-3.0": [
  44703. "PHP License v3.0",
  44704. true,
  44705. false
  44706. ],
  44707. "PHP-3.01": [
  44708. "PHP License v3.01",
  44709. true,
  44710. false
  44711. ],
  44712. "Plexus": [
  44713. "Plexus Classworlds License",
  44714. false,
  44715. false
  44716. ],
  44717. "PolyForm-Noncommercial-1.0.0": [
  44718. "PolyForm Noncommercial License 1.0.0",
  44719. false,
  44720. false
  44721. ],
  44722. "PolyForm-Small-Business-1.0.0": [
  44723. "PolyForm Small Business License 1.0.0",
  44724. false,
  44725. false
  44726. ],
  44727. "PostgreSQL": [
  44728. "PostgreSQL License",
  44729. true,
  44730. false
  44731. ],
  44732. "PSF-2.0": [
  44733. "Python Software Foundation License 2.0",
  44734. false,
  44735. false
  44736. ],
  44737. "psfrag": [
  44738. "psfrag License",
  44739. false,
  44740. false
  44741. ],
  44742. "psutils": [
  44743. "psutils License",
  44744. false,
  44745. false
  44746. ],
  44747. "Python-2.0": [
  44748. "Python License 2.0",
  44749. true,
  44750. false
  44751. ],
  44752. "Qhull": [
  44753. "Qhull License",
  44754. false,
  44755. false
  44756. ],
  44757. "QPL-1.0": [
  44758. "Q Public License 1.0",
  44759. true,
  44760. false
  44761. ],
  44762. "Rdisc": [
  44763. "Rdisc License",
  44764. false,
  44765. false
  44766. ],
  44767. "RHeCos-1.1": [
  44768. "Red Hat eCos Public License v1.1",
  44769. false,
  44770. false
  44771. ],
  44772. "RPL-1.1": [
  44773. "Reciprocal Public License 1.1",
  44774. true,
  44775. false
  44776. ],
  44777. "RPL-1.5": [
  44778. "Reciprocal Public License 1.5",
  44779. true,
  44780. false
  44781. ],
  44782. "RPSL-1.0": [
  44783. "RealNetworks Public Source License v1.0",
  44784. true,
  44785. false
  44786. ],
  44787. "RSA-MD": [
  44788. "RSA Message-Digest License",
  44789. false,
  44790. false
  44791. ],
  44792. "RSCPL": [
  44793. "Ricoh Source Code Public License",
  44794. true,
  44795. false
  44796. ],
  44797. "Ruby": [
  44798. "Ruby License",
  44799. false,
  44800. false
  44801. ],
  44802. "SAX-PD": [
  44803. "Sax Public Domain Notice",
  44804. false,
  44805. false
  44806. ],
  44807. "Saxpath": [
  44808. "Saxpath License",
  44809. false,
  44810. false
  44811. ],
  44812. "SCEA": [
  44813. "SCEA Shared Source License",
  44814. false,
  44815. false
  44816. ],
  44817. "Sendmail": [
  44818. "Sendmail License",
  44819. false,
  44820. false
  44821. ],
  44822. "Sendmail-8.23": [
  44823. "Sendmail License 8.23",
  44824. false,
  44825. false
  44826. ],
  44827. "SGI-B-1.0": [
  44828. "SGI Free Software License B v1.0",
  44829. false,
  44830. false
  44831. ],
  44832. "SGI-B-1.1": [
  44833. "SGI Free Software License B v1.1",
  44834. false,
  44835. false
  44836. ],
  44837. "SGI-B-2.0": [
  44838. "SGI Free Software License B v2.0",
  44839. false,
  44840. false
  44841. ],
  44842. "SHL-0.5": [
  44843. "Solderpad Hardware License v0.5",
  44844. false,
  44845. false
  44846. ],
  44847. "SHL-0.51": [
  44848. "Solderpad Hardware License, Version 0.51",
  44849. false,
  44850. false
  44851. ],
  44852. "SimPL-2.0": [
  44853. "Simple Public License 2.0",
  44854. true,
  44855. false
  44856. ],
  44857. "SISSL": [
  44858. "Sun Industry Standards Source License v1.1",
  44859. true,
  44860. false
  44861. ],
  44862. "SISSL-1.2": [
  44863. "Sun Industry Standards Source License v1.2",
  44864. false,
  44865. false
  44866. ],
  44867. "Sleepycat": [
  44868. "Sleepycat License",
  44869. true,
  44870. false
  44871. ],
  44872. "SMLNJ": [
  44873. "Standard ML of New Jersey License",
  44874. false,
  44875. false
  44876. ],
  44877. "SMPPL": [
  44878. "Secure Messaging Protocol Public License",
  44879. false,
  44880. false
  44881. ],
  44882. "SNIA": [
  44883. "SNIA Public License 1.1",
  44884. false,
  44885. false
  44886. ],
  44887. "Spencer-86": [
  44888. "Spencer License 86",
  44889. false,
  44890. false
  44891. ],
  44892. "Spencer-94": [
  44893. "Spencer License 94",
  44894. false,
  44895. false
  44896. ],
  44897. "Spencer-99": [
  44898. "Spencer License 99",
  44899. false,
  44900. false
  44901. ],
  44902. "SPL-1.0": [
  44903. "Sun Public License v1.0",
  44904. true,
  44905. false
  44906. ],
  44907. "SSH-OpenSSH": [
  44908. "SSH OpenSSH license",
  44909. false,
  44910. false
  44911. ],
  44912. "SSH-short": [
  44913. "SSH short notice",
  44914. false,
  44915. false
  44916. ],
  44917. "SSPL-1.0": [
  44918. "Server Side Public License, v 1",
  44919. false,
  44920. false
  44921. ],
  44922. "StandardML-NJ": [
  44923. "Standard ML of New Jersey License",
  44924. false,
  44925. true
  44926. ],
  44927. "SugarCRM-1.1.3": [
  44928. "SugarCRM Public License v1.1.3",
  44929. false,
  44930. false
  44931. ],
  44932. "SWL": [
  44933. "Scheme Widget Library (SWL) Software License Agreement",
  44934. false,
  44935. false
  44936. ],
  44937. "TAPR-OHL-1.0": [
  44938. "TAPR Open Hardware License v1.0",
  44939. false,
  44940. false
  44941. ],
  44942. "TCL": [
  44943. "TCL/TK License",
  44944. false,
  44945. false
  44946. ],
  44947. "TCP-wrappers": [
  44948. "TCP Wrappers License",
  44949. false,
  44950. false
  44951. ],
  44952. "TMate": [
  44953. "TMate Open Source License",
  44954. false,
  44955. false
  44956. ],
  44957. "TORQUE-1.1": [
  44958. "TORQUE v2.5+ Software License v1.1",
  44959. false,
  44960. false
  44961. ],
  44962. "TOSL": [
  44963. "Trusster Open Source License",
  44964. false,
  44965. false
  44966. ],
  44967. "TU-Berlin-1.0": [
  44968. "Technische Universitaet Berlin License 1.0",
  44969. false,
  44970. false
  44971. ],
  44972. "TU-Berlin-2.0": [
  44973. "Technische Universitaet Berlin License 2.0",
  44974. false,
  44975. false
  44976. ],
  44977. "UCL-1.0": [
  44978. "Upstream Compatibility License v1.0",
  44979. true,
  44980. false
  44981. ],
  44982. "Unicode-DFS-2015": [
  44983. "Unicode License Agreement - Data Files and Software (2015)",
  44984. false,
  44985. false
  44986. ],
  44987. "Unicode-DFS-2016": [
  44988. "Unicode License Agreement - Data Files and Software (2016)",
  44989. true,
  44990. false
  44991. ],
  44992. "Unicode-TOU": [
  44993. "Unicode Terms of Use",
  44994. false,
  44995. false
  44996. ],
  44997. "Unlicense": [
  44998. "The Unlicense",
  44999. true,
  45000. false
  45001. ],
  45002. "UPL-1.0": [
  45003. "Universal Permissive License v1.0",
  45004. true,
  45005. false
  45006. ],
  45007. "Vim": [
  45008. "Vim License",
  45009. false,
  45010. false
  45011. ],
  45012. "VOSTROM": [
  45013. "VOSTROM Public License for Open Source",
  45014. false,
  45015. false
  45016. ],
  45017. "VSL-1.0": [
  45018. "Vovida Software License v1.0",
  45019. true,
  45020. false
  45021. ],
  45022. "W3C": [
  45023. "W3C Software Notice and License (2002-12-31)",
  45024. true,
  45025. false
  45026. ],
  45027. "W3C-19980720": [
  45028. "W3C Software Notice and License (1998-07-20)",
  45029. false,
  45030. false
  45031. ],
  45032. "W3C-20150513": [
  45033. "W3C Software Notice and Document License (2015-05-13)",
  45034. false,
  45035. false
  45036. ],
  45037. "Watcom-1.0": [
  45038. "Sybase Open Watcom Public License 1.0",
  45039. true,
  45040. false
  45041. ],
  45042. "Wsuipa": [
  45043. "Wsuipa License",
  45044. false,
  45045. false
  45046. ],
  45047. "WTFPL": [
  45048. "Do What The F*ck You Want To Public License",
  45049. false,
  45050. false
  45051. ],
  45052. "wxWindows": [
  45053. "wxWindows Library License",
  45054. true,
  45055. true
  45056. ],
  45057. "X11": [
  45058. "X11 License",
  45059. false,
  45060. false
  45061. ],
  45062. "Xerox": [
  45063. "Xerox License",
  45064. false,
  45065. false
  45066. ],
  45067. "XFree86-1.1": [
  45068. "XFree86 License 1.1",
  45069. false,
  45070. false
  45071. ],
  45072. "xinetd": [
  45073. "xinetd License",
  45074. false,
  45075. false
  45076. ],
  45077. "Xnet": [
  45078. "X.Net License",
  45079. true,
  45080. false
  45081. ],
  45082. "xpp": [
  45083. "XPP License",
  45084. false,
  45085. false
  45086. ],
  45087. "XSkat": [
  45088. "XSkat License",
  45089. false,
  45090. false
  45091. ],
  45092. "YPL-1.0": [
  45093. "Yahoo! Public License v1.0",
  45094. false,
  45095. false
  45096. ],
  45097. "YPL-1.1": [
  45098. "Yahoo! Public License v1.1",
  45099. false,
  45100. false
  45101. ],
  45102. "Zed": [
  45103. "Zed License",
  45104. false,
  45105. false
  45106. ],
  45107. "Zend-2.0": [
  45108. "Zend License v2.0",
  45109. false,
  45110. false
  45111. ],
  45112. "Zimbra-1.3": [
  45113. "Zimbra Public License v1.3",
  45114. false,
  45115. false
  45116. ],
  45117. "Zimbra-1.4": [
  45118. "Zimbra Public License v1.4",
  45119. false,
  45120. false
  45121. ],
  45122. "Zlib": [
  45123. "zlib License",
  45124. true,
  45125. false
  45126. ],
  45127. "zlib-acknowledgement": [
  45128. "zlib/libpng License with Acknowledgement",
  45129. false,
  45130. false
  45131. ],
  45132. "ZPL-1.1": [
  45133. "Zope Public License 1.1",
  45134. false,
  45135. false
  45136. ],
  45137. "ZPL-2.0": [
  45138. "Zope Public License 2.0",
  45139. true,
  45140. false
  45141. ],
  45142. "ZPL-2.1": [
  45143. "Zope Public License 2.1",
  45144. true,
  45145. false
  45146. ]
  45147. }<?php
  45148. namespace Composer\Spdx;
  45149. class SpdxLicenses
  45150. {
  45151. const LICENSES_FILE = 'spdx-licenses.json';
  45152. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  45153. private $licenses;
  45154. private $licensesExpression;
  45155. private $exceptions;
  45156. private $exceptionsExpression;
  45157. public function __construct()
  45158. {
  45159. $this->loadLicenses();
  45160. $this->loadExceptions();
  45161. }
  45162. public function getLicenseByIdentifier($identifier)
  45163. {
  45164. $key = strtolower($identifier);
  45165. if (!isset($this->licenses[$key])) {
  45166. return null;
  45167. }
  45168. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  45169. return array(
  45170. $name,
  45171. $isOsiApproved,
  45172. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  45173. $isDeprecatedLicenseId,
  45174. );
  45175. }
  45176. public function getLicenses()
  45177. {
  45178. return $this->licenses;
  45179. }
  45180. public function getExceptionByIdentifier($identifier)
  45181. {
  45182. $key = strtolower($identifier);
  45183. if (!isset($this->exceptions[$key])) {
  45184. return null;
  45185. }
  45186. list($identifier, $name) = $this->exceptions[$key];
  45187. return array(
  45188. $name,
  45189. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  45190. );
  45191. }
  45192. public function getIdentifierByName($name)
  45193. {
  45194. foreach ($this->licenses as $licenseData) {
  45195. if ($licenseData[1] === $name) {
  45196. return $licenseData[0];
  45197. }
  45198. }
  45199. foreach ($this->exceptions as $licenseData) {
  45200. if ($licenseData[1] === $name) {
  45201. return $licenseData[0];
  45202. }
  45203. }
  45204. return null;
  45205. }
  45206. public function isOsiApprovedByIdentifier($identifier)
  45207. {
  45208. return $this->licenses[strtolower($identifier)][2];
  45209. }
  45210. public function isDeprecatedByIdentifier($identifier)
  45211. {
  45212. return $this->licenses[strtolower($identifier)][3];
  45213. }
  45214. public function validate($license)
  45215. {
  45216. if (is_array($license)) {
  45217. $count = count($license);
  45218. if ($count !== count(array_filter($license, 'is_string'))) {
  45219. throw new \InvalidArgumentException('Array of strings expected.');
  45220. }
  45221. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  45222. }
  45223. if (!is_string($license)) {
  45224. throw new \InvalidArgumentException(sprintf(
  45225. 'Array or String expected, %s given.',
  45226. gettype($license)
  45227. ));
  45228. }
  45229. return $this->isValidLicenseString($license);
  45230. }
  45231. public static function getResourcesDir()
  45232. {
  45233. return dirname(__DIR__) . '/res';
  45234. }
  45235. private function loadLicenses()
  45236. {
  45237. if (null !== $this->licenses) {
  45238. return;
  45239. }
  45240. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  45241. if (false === $json) {
  45242. throw new \RuntimeException('Missing license file in ' . self::getResourcesDir() . '/' . self::LICENSES_FILE);
  45243. }
  45244. $this->licenses = array();
  45245. foreach (json_decode($json, true) as $identifier => $license) {
  45246. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  45247. }
  45248. }
  45249. private function loadExceptions()
  45250. {
  45251. if (null !== $this->exceptions) {
  45252. return;
  45253. }
  45254. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  45255. if (false === $json) {
  45256. throw new \RuntimeException('Missing exceptions file in ' . self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  45257. }
  45258. $this->exceptions = array();
  45259. foreach (json_decode($json, true) as $identifier => $exception) {
  45260. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  45261. }
  45262. }
  45263. private function getLicensesExpression()
  45264. {
  45265. if (null === $this->licensesExpression) {
  45266. $licenses = array_map('preg_quote', array_keys($this->licenses));
  45267. rsort($licenses);
  45268. $licenses = implode('|', $licenses);
  45269. $this->licensesExpression = $licenses;
  45270. }
  45271. return $this->licensesExpression;
  45272. }
  45273. private function getExceptionsExpression()
  45274. {
  45275. if (null === $this->exceptionsExpression) {
  45276. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  45277. rsort($exceptions);
  45278. $exceptions = implode('|', $exceptions);
  45279. $this->exceptionsExpression = $exceptions;
  45280. }
  45281. return $this->exceptionsExpression;
  45282. }
  45283. private function isValidLicenseString($license)
  45284. {
  45285. if (isset($this->licenses[strtolower($license)])) {
  45286. return true;
  45287. }
  45288. $licenses = $this->getLicensesExpression();
  45289. $exceptions = $this->getExceptionsExpression();
  45290. $regex = <<<REGEX
  45291. {
  45292. (?(DEFINE)
  45293. # idstring: 1*( ALPHA / DIGIT / - / . )
  45294. (?<idstring>[\pL\pN.-]{1,})
  45295. # license-id: taken from list
  45296. (?<licenseid>${licenses})
  45297. # license-exception-id: taken from list
  45298. (?<licenseexceptionid>${exceptions})
  45299. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  45300. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  45301. # simple-expresssion: license-id / license-id+ / license-ref
  45302. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  45303. # compound-expression: 1*(
  45304. # simple-expression /
  45305. # simple-expression WITH license-exception-id /
  45306. # compound-expression AND compound-expression /
  45307. # compound-expression OR compound-expression
  45308. # ) / ( compound-expression ) )
  45309. (?<compound_head>
  45310. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  45311. | \( \s* (?&compound_expression) \s* \)
  45312. )
  45313. (?<compound_expression>
  45314. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  45315. )
  45316. # license-expression: 1*1(simple-expression / compound-expression)
  45317. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  45318. ) # end of define
  45319. ^(NONE | NOASSERTION | (?&license_expression))$
  45320. }xi
  45321. REGEX;
  45322. $match = preg_match($regex, $license);
  45323. if (0 === $match) {
  45324. return false;
  45325. }
  45326. if (false === $match) {
  45327. throw new \RuntimeException('Regex failed to compile/run.');
  45328. }
  45329. return true;
  45330. }
  45331. }
  45332. MIT License
  45333. Copyright (c) 2017 Composer
  45334. Permission is hereby granted, free of charge, to any person obtaining a copy
  45335. of this software and associated documentation files (the "Software"), to deal
  45336. in the Software without restriction, including without limitation the rights
  45337. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  45338. copies of the Software, and to permit persons to whom the Software is
  45339. furnished to do so, subject to the following conditions:
  45340. The above copyright notice and this permission notice shall be included in all
  45341. copies or substantial portions of the Software.
  45342. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  45343. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  45344. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  45345. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  45346. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  45347. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  45348. SOFTWARE.
  45349. <?php
  45350. namespace Composer\XdebugHandler;
  45351. class PhpConfig
  45352. {
  45353. public function useOriginal()
  45354. {
  45355. $this->getDataAndReset();
  45356. return array();
  45357. }
  45358. public function useStandard()
  45359. {
  45360. if ($data = $this->getDataAndReset()) {
  45361. return array('-n', '-c', $data['tmpIni']);
  45362. }
  45363. return array();
  45364. }
  45365. public function usePersistent()
  45366. {
  45367. if ($data = $this->getDataAndReset()) {
  45368. $this->updateEnv('PHPRC', $data['tmpIni']);
  45369. $this->updateEnv('PHP_INI_SCAN_DIR', '');
  45370. }
  45371. return array();
  45372. }
  45373. private function getDataAndReset()
  45374. {
  45375. if ($data = XdebugHandler::getRestartSettings()) {
  45376. $this->updateEnv('PHPRC', $data['phprc']);
  45377. $this->updateEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  45378. }
  45379. return $data;
  45380. }
  45381. private function updateEnv($name, $value)
  45382. {
  45383. Process::setEnv($name, false !== $value ? $value : null);
  45384. }
  45385. }
  45386. <?php
  45387. namespace Composer\XdebugHandler;
  45388. class Process
  45389. {
  45390. public static function escape($arg, $meta = true, $module = false)
  45391. {
  45392. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  45393. return "'".str_replace("'", "'\\''", $arg)."'";
  45394. }
  45395. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  45396. $arg = preg_replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  45397. if ($meta) {
  45398. $meta = $dquotes || preg_match('/%[^%]+%/', $arg);
  45399. if (!$meta) {
  45400. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  45401. } elseif ($module && !$dquotes && $quote) {
  45402. $meta = false;
  45403. }
  45404. }
  45405. if ($quote) {
  45406. $arg = '"'.preg_replace('/(\\\\*)$/', '$1$1', $arg).'"';
  45407. }
  45408. if ($meta) {
  45409. $arg = preg_replace('/(["^&|<>()%])/', '^$1', $arg);
  45410. }
  45411. return $arg;
  45412. }
  45413. public static function escapeShellCommand(array $args)
  45414. {
  45415. $cmd = self::escape(array_shift($args), true, true);
  45416. foreach ($args as $arg) {
  45417. $cmd .= ' '.self::escape($arg);
  45418. }
  45419. return $cmd;
  45420. }
  45421. public static function setEnv($name, $value = null)
  45422. {
  45423. $unset = null === $value;
  45424. if (!putenv($unset ? $name : $name.'='.$value)) {
  45425. return false;
  45426. }
  45427. if ($unset) {
  45428. unset($_SERVER[$name]);
  45429. } else {
  45430. $_SERVER[$name] = $value;
  45431. }
  45432. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  45433. if ($unset) {
  45434. unset($_ENV[$name]);
  45435. } else {
  45436. $_ENV[$name] = $value;
  45437. }
  45438. }
  45439. return true;
  45440. }
  45441. }
  45442. <?php
  45443. namespace Composer\XdebugHandler;
  45444. use Psr\Log\LoggerInterface;
  45445. use Psr\Log\LogLevel;
  45446. class Status
  45447. {
  45448. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  45449. const CHECK = 'Check';
  45450. const ERROR = 'Error';
  45451. const INFO = 'Info';
  45452. const NORESTART = 'NoRestart';
  45453. const RESTART = 'Restart';
  45454. const RESTARTING = 'Restarting';
  45455. const RESTARTED = 'Restarted';
  45456. private $debug;
  45457. private $envAllowXdebug;
  45458. private $loaded;
  45459. private $logger;
  45460. private $modeOff;
  45461. private $time;
  45462. public function __construct($envAllowXdebug, $debug)
  45463. {
  45464. $start = getenv(self::ENV_RESTART);
  45465. Process::setEnv(self::ENV_RESTART);
  45466. $this->time = $start ? round((microtime(true) - $start) * 1000) : 0;
  45467. $this->envAllowXdebug = $envAllowXdebug;
  45468. $this->debug = $debug && defined('STDERR');
  45469. }
  45470. public function setLogger(LoggerInterface $logger)
  45471. {
  45472. $this->logger = $logger;
  45473. }
  45474. public function report($op, $data)
  45475. {
  45476. if ($this->logger || $this->debug) {
  45477. call_user_func(array($this, 'report'.$op), $data);
  45478. }
  45479. }
  45480. private function output($text, $level = null)
  45481. {
  45482. if ($this->logger) {
  45483. $this->logger->log($level ?: LogLevel::DEBUG, $text);
  45484. }
  45485. if ($this->debug) {
  45486. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  45487. }
  45488. }
  45489. private function reportCheck($loaded)
  45490. {
  45491. list($version, $mode) = explode('|', $loaded);
  45492. if ($version) {
  45493. $this->loaded = '('.$version.')'.($mode ? ' mode='.$mode : '');
  45494. }
  45495. $this->modeOff = $mode === 'off';
  45496. $this->output('Checking '.$this->envAllowXdebug);
  45497. }
  45498. private function reportError($error)
  45499. {
  45500. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  45501. }
  45502. private function reportInfo($info)
  45503. {
  45504. $this->output($info);
  45505. }
  45506. private function reportNoRestart()
  45507. {
  45508. $this->output($this->getLoadedMessage());
  45509. if ($this->loaded) {
  45510. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  45511. if (!getenv($this->envAllowXdebug)) {
  45512. $text .= ' Allowed by '.($this->modeOff ? 'mode' : 'application');
  45513. }
  45514. $this->output($text);
  45515. }
  45516. }
  45517. private function reportRestart()
  45518. {
  45519. $this->output($this->getLoadedMessage());
  45520. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  45521. }
  45522. private function reportRestarted()
  45523. {
  45524. $loaded = $this->getLoadedMessage();
  45525. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  45526. $level = $this->loaded ? LogLevel::WARNING : null;
  45527. $this->output($text, $level);
  45528. }
  45529. private function reportRestarting($command)
  45530. {
  45531. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  45532. $this->output($text);
  45533. $text = 'Running '.$command;
  45534. $this->output($text);
  45535. }
  45536. private function getEnvAllow()
  45537. {
  45538. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  45539. }
  45540. private function getLoadedMessage()
  45541. {
  45542. $loaded = $this->loaded ? sprintf('loaded %s', $this->loaded) : 'not loaded';
  45543. return 'The Xdebug extension is '.$loaded;
  45544. }
  45545. }
  45546. <?php
  45547. namespace Composer\XdebugHandler;
  45548. use Psr\Log\LoggerInterface;
  45549. class XdebugHandler
  45550. {
  45551. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  45552. const SUFFIX_INIS = '_ORIGINAL_INIS';
  45553. const RESTART_ID = 'internal';
  45554. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  45555. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  45556. protected $tmpIni;
  45557. private static $inRestart;
  45558. private static $name;
  45559. private static $skipped;
  45560. private static $xdebugActive;
  45561. private $cli;
  45562. private $debug;
  45563. private $envAllowXdebug;
  45564. private $envOriginalInis;
  45565. private $loaded;
  45566. private $mode;
  45567. private $persistent;
  45568. private $script;
  45569. private $statusWriter;
  45570. public function __construct($envPrefix)
  45571. {
  45572. if (!is_string($envPrefix) || empty($envPrefix)) {
  45573. throw new \RuntimeException('Invalid constructor parameter');
  45574. }
  45575. self::$name = strtoupper($envPrefix);
  45576. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  45577. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  45578. if (extension_loaded('xdebug')) {
  45579. $this->loaded = phpversion('xdebug') ?: 'unknown';
  45580. if (version_compare($this->loaded, '3.1', '>=')) {
  45581. $modes = xdebug_info('mode');
  45582. $this->mode = empty($modes) ? 'off' : implode(',', $modes);
  45583. } elseif (false !== ($mode = ini_get('xdebug.mode'))) {
  45584. $this->mode = getenv('XDEBUG_MODE') ?: ($mode ?: 'off');
  45585. if (preg_match('/^,+$/', str_replace(' ', '', $this->mode))) {
  45586. $this->mode = 'off';
  45587. }
  45588. }
  45589. }
  45590. self::$xdebugActive = $this->loaded && $this->mode !== 'off';
  45591. if ($this->cli = PHP_SAPI === 'cli') {
  45592. $this->debug = getenv(self::DEBUG);
  45593. }
  45594. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  45595. }
  45596. public function setLogger(LoggerInterface $logger)
  45597. {
  45598. $this->statusWriter->setLogger($logger);
  45599. return $this;
  45600. }
  45601. public function setMainScript($script)
  45602. {
  45603. $this->script = $script;
  45604. return $this;
  45605. }
  45606. public function setPersistent()
  45607. {
  45608. $this->persistent = true;
  45609. return $this;
  45610. }
  45611. public function check()
  45612. {
  45613. $this->notify(Status::CHECK, $this->loaded.'|'.$this->mode);
  45614. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  45615. if (empty($envArgs[0]) && $this->requiresRestart(self::$xdebugActive)) {
  45616. $this->notify(Status::RESTART);
  45617. if ($this->prepareRestart()) {
  45618. $command = $this->getCommand();
  45619. $this->restart($command);
  45620. }
  45621. return;
  45622. }
  45623. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  45624. $this->notify(Status::RESTARTED);
  45625. Process::setEnv($this->envAllowXdebug);
  45626. self::$inRestart = true;
  45627. if (!$this->loaded) {
  45628. self::$skipped = $envArgs[1];
  45629. }
  45630. $this->tryEnableSignals();
  45631. $this->setEnvRestartSettings($envArgs);
  45632. return;
  45633. }
  45634. $this->notify(Status::NORESTART);
  45635. if ($settings = self::getRestartSettings()) {
  45636. $this->syncSettings($settings);
  45637. }
  45638. }
  45639. public static function getAllIniFiles()
  45640. {
  45641. if (!empty(self::$name)) {
  45642. $env = getenv(self::$name.self::SUFFIX_INIS);
  45643. if (false !== $env) {
  45644. return explode(PATH_SEPARATOR, $env);
  45645. }
  45646. }
  45647. $paths = array((string) php_ini_loaded_file());
  45648. if ($scanned = php_ini_scanned_files()) {
  45649. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  45650. }
  45651. return $paths;
  45652. }
  45653. public static function getRestartSettings()
  45654. {
  45655. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  45656. if (count($envArgs) !== 6
  45657. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  45658. return null;
  45659. }
  45660. return array(
  45661. 'tmpIni' => $envArgs[0],
  45662. 'scannedInis' => (bool) $envArgs[1],
  45663. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  45664. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  45665. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  45666. 'skipped' => $envArgs[5],
  45667. );
  45668. }
  45669. public static function getSkippedVersion()
  45670. {
  45671. return (string) self::$skipped;
  45672. }
  45673. public static function isXdebugActive()
  45674. {
  45675. return self::$xdebugActive;
  45676. }
  45677. protected function requiresRestart($default)
  45678. {
  45679. return $default;
  45680. }
  45681. protected function restart($command)
  45682. {
  45683. $this->doRestart($command);
  45684. }
  45685. private function doRestart(array $command)
  45686. {
  45687. $this->tryEnableSignals();
  45688. $this->notify(Status::RESTARTING, implode(' ', $command));
  45689. if (PHP_VERSION_ID >= 70400) {
  45690. $cmd = $command;
  45691. } else {
  45692. $cmd = Process::escapeShellCommand($command);
  45693. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  45694. $cmd = '"'.$cmd.'"';
  45695. }
  45696. }
  45697. $process = proc_open($cmd, array(), $pipes);
  45698. if (is_resource($process)) {
  45699. $exitCode = proc_close($process);
  45700. }
  45701. if (!isset($exitCode)) {
  45702. $this->notify(Status::ERROR, 'Unable to restart process');
  45703. $exitCode = -1;
  45704. } else {
  45705. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  45706. }
  45707. if ($this->debug === '2') {
  45708. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  45709. } else {
  45710. @unlink($this->tmpIni);
  45711. }
  45712. exit($exitCode);
  45713. }
  45714. private function prepareRestart()
  45715. {
  45716. $error = '';
  45717. $iniFiles = self::getAllIniFiles();
  45718. $scannedInis = count($iniFiles) > 1;
  45719. $tmpDir = sys_get_temp_dir();
  45720. if (!$this->cli) {
  45721. $error = 'Unsupported SAPI: '.PHP_SAPI;
  45722. } elseif (!defined('PHP_BINARY')) {
  45723. $error = 'PHP version is too old: '.PHP_VERSION;
  45724. } elseif (!$this->checkConfiguration($info)) {
  45725. $error = $info;
  45726. } elseif (!$this->checkScanDirConfig()) {
  45727. $error = 'PHP version does not report scanned inis: '.PHP_VERSION;
  45728. } elseif (!$this->checkMainScript()) {
  45729. $error = 'Unable to access main script: '.$this->script;
  45730. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  45731. $error = $error ?: 'Unable to create temp ini file at: '.$tmpDir;
  45732. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  45733. $error = 'Unable to set environment variables';
  45734. }
  45735. if ($error) {
  45736. $this->notify(Status::ERROR, $error);
  45737. }
  45738. return empty($error);
  45739. }
  45740. private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
  45741. {
  45742. if (!$this->tmpIni = @tempnam($tmpDir, '')) {
  45743. return false;
  45744. }
  45745. if (empty($iniFiles[0])) {
  45746. array_shift($iniFiles);
  45747. }
  45748. $content = '';
  45749. $sectionRegex = '/^\s*\[(?:PATH|HOST)\s*=/mi';
  45750. $xdebugRegex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  45751. foreach ($iniFiles as $file) {
  45752. if (($data = @file_get_contents($file)) === false) {
  45753. $error = 'Unable to read ini: '.$file;
  45754. return false;
  45755. }
  45756. if (preg_match($sectionRegex, $data, $matches, PREG_OFFSET_CAPTURE)) {
  45757. $data = substr($data, 0, $matches[0][1]);
  45758. }
  45759. $content .= preg_replace($xdebugRegex, ';$1', $data).PHP_EOL;
  45760. }
  45761. if ($config = parse_ini_string($content)) {
  45762. $loaded = ini_get_all(null, false);
  45763. $content .= $this->mergeLoadedConfig($loaded, $config);
  45764. }
  45765. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  45766. return @file_put_contents($this->tmpIni, $content);
  45767. }
  45768. private function getCommand()
  45769. {
  45770. $php = array(PHP_BINARY);
  45771. $args = array_slice($_SERVER['argv'], 1);
  45772. if (!$this->persistent) {
  45773. array_push($php, '-n', '-c', $this->tmpIni);
  45774. }
  45775. return array_merge($php, array($this->script), $args);
  45776. }
  45777. private function setEnvironment($scannedInis, array $iniFiles)
  45778. {
  45779. $scanDir = getenv('PHP_INI_SCAN_DIR');
  45780. $phprc = getenv('PHPRC');
  45781. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  45782. return false;
  45783. }
  45784. if ($this->persistent) {
  45785. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  45786. return false;
  45787. }
  45788. }
  45789. $envArgs = array(
  45790. self::RESTART_ID,
  45791. $this->loaded,
  45792. (int) $scannedInis,
  45793. false === $scanDir ? '*' : $scanDir,
  45794. false === $phprc ? '*' : $phprc,
  45795. );
  45796. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  45797. }
  45798. private function notify($op, $data = null)
  45799. {
  45800. $this->statusWriter->report($op, $data);
  45801. }
  45802. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig)
  45803. {
  45804. $content = '';
  45805. foreach ($loadedConfig as $name => $value) {
  45806. if (!is_string($value)
  45807. || strpos($name, 'xdebug') === 0
  45808. || $name === 'apc.mmap_file_mask') {
  45809. continue;
  45810. }
  45811. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  45812. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  45813. }
  45814. }
  45815. return $content;
  45816. }
  45817. private function checkMainScript()
  45818. {
  45819. if (null !== $this->script) {
  45820. return file_exists($this->script) || '--' === $this->script;
  45821. }
  45822. if (file_exists($this->script = $_SERVER['argv'][0])) {
  45823. return true;
  45824. }
  45825. $options = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false;
  45826. $trace = debug_backtrace($options);
  45827. if (($main = end($trace)) && isset($main['file'])) {
  45828. return file_exists($this->script = $main['file']);
  45829. }
  45830. return false;
  45831. }
  45832. private function setEnvRestartSettings($envArgs)
  45833. {
  45834. $settings = array(
  45835. php_ini_loaded_file(),
  45836. $envArgs[2],
  45837. $envArgs[3],
  45838. $envArgs[4],
  45839. getenv($this->envOriginalInis),
  45840. self::$skipped,
  45841. );
  45842. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  45843. }
  45844. private function syncSettings(array $settings)
  45845. {
  45846. if (false === getenv($this->envOriginalInis)) {
  45847. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  45848. }
  45849. self::$skipped = $settings['skipped'];
  45850. $this->notify(Status::INFO, 'Process called with existing restart settings');
  45851. }
  45852. private function checkScanDirConfig()
  45853. {
  45854. return !(getenv('PHP_INI_SCAN_DIR')
  45855. && !PHP_CONFIG_FILE_SCAN_DIR
  45856. && (PHP_VERSION_ID < 70113
  45857. || PHP_VERSION_ID === 70200));
  45858. }
  45859. private function checkConfiguration(&$info)
  45860. {
  45861. if (!function_exists('proc_open')) {
  45862. $info = 'proc_open function is disabled';
  45863. return false;
  45864. }
  45865. if (extension_loaded('uopz') && !ini_get('uopz.disable')) {
  45866. if (function_exists('uopz_allow_exit')) {
  45867. @uopz_allow_exit(true);
  45868. } else {
  45869. $info = 'uopz extension is not compatible';
  45870. return false;
  45871. }
  45872. }
  45873. $workingDir = getcwd();
  45874. if (0 === strpos($workingDir, '\\\\')) {
  45875. if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 70400) {
  45876. $info = 'cmd.exe does not support UNC paths: '.$workingDir;
  45877. return false;
  45878. }
  45879. }
  45880. return true;
  45881. }
  45882. private function tryEnableSignals()
  45883. {
  45884. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  45885. pcntl_async_signals(true);
  45886. $message = 'Async signals enabled';
  45887. if (!self::$inRestart) {
  45888. pcntl_signal(SIGINT, SIG_IGN);
  45889. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  45890. pcntl_signal(SIGINT, SIG_DFL);
  45891. }
  45892. }
  45893. if (!self::$inRestart && function_exists('sapi_windows_set_ctrl_handler')) {
  45894. sapi_windows_set_ctrl_handler(function ($evt) {});
  45895. }
  45896. }
  45897. }
  45898. MIT License
  45899. Copyright (c) 2016
  45900. Permission is hereby granted, free of charge, to any person obtaining a copy
  45901. of this software and associated documentation files (the "Software"), to deal
  45902. in the Software without restriction, including without limitation the rights
  45903. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  45904. copies of the Software, and to permit persons to whom the Software is
  45905. furnished to do so, subject to the following conditions:
  45906. The above copyright notice and this permission notice shall be included in all
  45907. copies or substantial portions of the Software.
  45908. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  45909. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  45910. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  45911. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  45912. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  45913. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  45914. SOFTWARE.
  45915. <?php
  45916. namespace JsonSchema\Constraints;
  45917. use JsonSchema\Entity\JsonPointer;
  45918. use JsonSchema\Exception\InvalidArgumentException;
  45919. use JsonSchema\Exception\ValidationException;
  45920. use JsonSchema\Validator;
  45921. class BaseConstraint
  45922. {
  45923. protected $errors = array();
  45924. protected $errorMask = Validator::ERROR_NONE;
  45925. protected $factory;
  45926. public function __construct(Factory $factory = null)
  45927. {
  45928. $this->factory = $factory ?: new Factory();
  45929. }
  45930. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  45931. {
  45932. $error = array(
  45933. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  45934. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  45935. 'message' => $message,
  45936. 'constraint' => $constraint,
  45937. 'context' => $this->factory->getErrorContext(),
  45938. );
  45939. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  45940. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  45941. }
  45942. if (is_array($more) && count($more) > 0) {
  45943. $error += $more;
  45944. }
  45945. $this->errors[] = $error;
  45946. $this->errorMask |= $error['context'];
  45947. }
  45948. public function addErrors(array $errors)
  45949. {
  45950. if ($errors) {
  45951. $this->errors = array_merge($this->errors, $errors);
  45952. $errorMask = &$this->errorMask;
  45953. array_walk($errors, function ($error) use (&$errorMask) {
  45954. if (isset($error['context'])) {
  45955. $errorMask |= $error['context'];
  45956. }
  45957. });
  45958. }
  45959. }
  45960. public function getErrors($errorContext = Validator::ERROR_ALL)
  45961. {
  45962. if ($errorContext === Validator::ERROR_ALL) {
  45963. return $this->errors;
  45964. }
  45965. return array_filter($this->errors, function ($error) use ($errorContext) {
  45966. if ($errorContext & $error['context']) {
  45967. return true;
  45968. }
  45969. });
  45970. }
  45971. public function numErrors($errorContext = Validator::ERROR_ALL)
  45972. {
  45973. if ($errorContext === Validator::ERROR_ALL) {
  45974. return count($this->errors);
  45975. }
  45976. return count($this->getErrors($errorContext));
  45977. }
  45978. public function isValid()
  45979. {
  45980. return !$this->getErrors();
  45981. }
  45982. public function reset()
  45983. {
  45984. $this->errors = array();
  45985. $this->errorMask = Validator::ERROR_NONE;
  45986. }
  45987. public function getErrorMask()
  45988. {
  45989. return $this->errorMask;
  45990. }
  45991. public static function arrayToObjectRecursive($array)
  45992. {
  45993. $json = json_encode($array);
  45994. if (json_last_error() !== \JSON_ERROR_NONE) {
  45995. $message = 'Unable to encode schema array as JSON';
  45996. if (function_exists('json_last_error_msg')) {
  45997. $message .= ': ' . json_last_error_msg();
  45998. }
  45999. throw new InvalidArgumentException($message);
  46000. }
  46001. return (object) json_decode($json);
  46002. }
  46003. }
  46004. <?php
  46005. namespace JsonSchema\Constraints;
  46006. use JsonSchema\Entity\JsonPointer;
  46007. class CollectionConstraint extends Constraint
  46008. {
  46009. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  46010. {
  46011. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  46012. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  46013. }
  46014. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  46015. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  46016. }
  46017. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  46018. $unique = $value;
  46019. if (is_array($value) && count($value)) {
  46020. $unique = array_map(function ($e) {
  46021. return var_export($e, true);
  46022. }, $value);
  46023. }
  46024. if (count(array_unique($unique)) != count($value)) {
  46025. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  46026. }
  46027. }
  46028. if (isset($schema->items)) {
  46029. $this->validateItems($value, $schema, $path, $i);
  46030. }
  46031. }
  46032. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  46033. {
  46034. if (is_object($schema->items)) {
  46035. foreach ($value as $k => &$v) {
  46036. $initErrors = $this->getErrors();
  46037. $this->checkUndefined($v, $schema->items, $path, $k);
  46038. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  46039. $secondErrors = $this->getErrors();
  46040. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  46041. }
  46042. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  46043. $this->errors = $secondErrors;
  46044. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  46045. $this->errors = $initErrors;
  46046. }
  46047. }
  46048. unset($v);
  46049. } else {
  46050. foreach ($value as $k => &$v) {
  46051. if (array_key_exists($k, $schema->items)) {
  46052. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  46053. } else {
  46054. if (property_exists($schema, 'additionalItems')) {
  46055. if ($schema->additionalItems !== false) {
  46056. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  46057. } else {
  46058. $this->addError(
  46059. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  46060. }
  46061. } else {
  46062. $this->checkUndefined($v, new \stdClass(), $path, $k);
  46063. }
  46064. }
  46065. }
  46066. unset($v);
  46067. if (count($value) > 0) {
  46068. for ($k = count($value); $k < count($schema->items); $k++) {
  46069. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  46070. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  46071. }
  46072. }
  46073. }
  46074. }
  46075. }
  46076. <?php
  46077. namespace JsonSchema\Constraints;
  46078. use JsonSchema\Entity\JsonPointer;
  46079. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  46080. {
  46081. protected $inlineSchemaProperty = '$schema';
  46082. const CHECK_MODE_NONE = 0x00000000;
  46083. const CHECK_MODE_NORMAL = 0x00000001;
  46084. const CHECK_MODE_TYPE_CAST = 0x00000002;
  46085. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  46086. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  46087. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  46088. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  46089. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  46090. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  46091. protected function incrementPath(JsonPointer $path = null, $i)
  46092. {
  46093. $path = $path ?: new JsonPointer('');
  46094. if ($i === null || $i === '') {
  46095. return $path;
  46096. }
  46097. $path = $path->withPropertyPaths(
  46098. array_merge(
  46099. $path->getPropertyPaths(),
  46100. array($i)
  46101. )
  46102. );
  46103. return $path;
  46104. }
  46105. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  46106. {
  46107. $validator = $this->factory->createInstanceFor('collection');
  46108. $validator->check($value, $schema, $path, $i);
  46109. $this->addErrors($validator->getErrors());
  46110. }
  46111. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  46112. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  46113. {
  46114. $validator = $this->factory->createInstanceFor('object');
  46115. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  46116. $this->addErrors($validator->getErrors());
  46117. }
  46118. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  46119. {
  46120. $validator = $this->factory->createInstanceFor('type');
  46121. $validator->check($value, $schema, $path, $i);
  46122. $this->addErrors($validator->getErrors());
  46123. }
  46124. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  46125. {
  46126. $validator = $this->factory->createInstanceFor('undefined');
  46127. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  46128. $this->addErrors($validator->getErrors());
  46129. }
  46130. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  46131. {
  46132. $validator = $this->factory->createInstanceFor('string');
  46133. $validator->check($value, $schema, $path, $i);
  46134. $this->addErrors($validator->getErrors());
  46135. }
  46136. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  46137. {
  46138. $validator = $this->factory->createInstanceFor('number');
  46139. $validator->check($value, $schema, $path, $i);
  46140. $this->addErrors($validator->getErrors());
  46141. }
  46142. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  46143. {
  46144. $validator = $this->factory->createInstanceFor('enum');
  46145. $validator->check($value, $schema, $path, $i);
  46146. $this->addErrors($validator->getErrors());
  46147. }
  46148. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  46149. {
  46150. $validator = $this->factory->createInstanceFor('format');
  46151. $validator->check($value, $schema, $path, $i);
  46152. $this->addErrors($validator->getErrors());
  46153. }
  46154. protected function getTypeCheck()
  46155. {
  46156. return $this->factory->getTypeCheck();
  46157. }
  46158. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  46159. {
  46160. $result = array_map(
  46161. function ($path) {
  46162. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  46163. },
  46164. $pointer->getPropertyPaths()
  46165. );
  46166. return trim(implode('', $result), '.');
  46167. }
  46168. }
  46169. <?php
  46170. namespace JsonSchema\Constraints;
  46171. use JsonSchema\Entity\JsonPointer;
  46172. interface ConstraintInterface
  46173. {
  46174. public function getErrors();
  46175. public function addErrors(array $errors);
  46176. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  46177. public function isValid();
  46178. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  46179. }
  46180. <?php
  46181. namespace JsonSchema\Constraints;
  46182. use JsonSchema\Entity\JsonPointer;
  46183. class EnumConstraint extends Constraint
  46184. {
  46185. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  46186. {
  46187. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  46188. return;
  46189. }
  46190. $type = gettype($element);
  46191. foreach ($schema->enum as $enum) {
  46192. $enumType = gettype($enum);
  46193. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  46194. if ((object) $element == $enum) {
  46195. return;
  46196. }
  46197. }
  46198. if ($type === gettype($enum)) {
  46199. if ($type == 'object') {
  46200. if ($element == $enum) {
  46201. return;
  46202. }
  46203. } elseif ($element === $enum) {
  46204. return;
  46205. }
  46206. }
  46207. }
  46208. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  46209. }
  46210. }
  46211. <?php
  46212. namespace JsonSchema\Constraints;
  46213. use JsonSchema\Exception\InvalidArgumentException;
  46214. use JsonSchema\SchemaStorage;
  46215. use JsonSchema\SchemaStorageInterface;
  46216. use JsonSchema\Uri\UriRetriever;
  46217. use JsonSchema\UriRetrieverInterface;
  46218. use JsonSchema\Validator;
  46219. class Factory
  46220. {
  46221. protected $schemaStorage;
  46222. protected $uriRetriever;
  46223. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  46224. private $typeCheck = array();
  46225. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  46226. protected $constraintMap = array(
  46227. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  46228. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  46229. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  46230. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  46231. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  46232. 'string' => 'JsonSchema\Constraints\StringConstraint',
  46233. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  46234. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  46235. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  46236. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  46237. 'validator' => 'JsonSchema\Validator'
  46238. );
  46239. private $instanceCache = array();
  46240. public function __construct(
  46241. SchemaStorageInterface $schemaStorage = null,
  46242. UriRetrieverInterface $uriRetriever = null,
  46243. $checkMode = Constraint::CHECK_MODE_NORMAL
  46244. ) {
  46245. $this->setConfig($checkMode);
  46246. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  46247. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  46248. }
  46249. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  46250. {
  46251. $this->checkMode = $checkMode;
  46252. }
  46253. public function addConfig($options)
  46254. {
  46255. $this->checkMode |= $options;
  46256. }
  46257. public function removeConfig($options)
  46258. {
  46259. $this->checkMode &= ~$options;
  46260. }
  46261. public function getConfig($options = null)
  46262. {
  46263. if ($options === null) {
  46264. return $this->checkMode;
  46265. }
  46266. return $this->checkMode & $options;
  46267. }
  46268. public function getUriRetriever()
  46269. {
  46270. return $this->uriRetriever;
  46271. }
  46272. public function getSchemaStorage()
  46273. {
  46274. return $this->schemaStorage;
  46275. }
  46276. public function getTypeCheck()
  46277. {
  46278. if (!isset($this->typeCheck[$this->checkMode])) {
  46279. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  46280. ? new TypeCheck\LooseTypeCheck()
  46281. : new TypeCheck\StrictTypeCheck();
  46282. }
  46283. return $this->typeCheck[$this->checkMode];
  46284. }
  46285. public function setConstraintClass($name, $class)
  46286. {
  46287. if (!class_exists($class)) {
  46288. throw new InvalidArgumentException('Unknown constraint ' . $name);
  46289. }
  46290. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  46291. throw new InvalidArgumentException('Invalid class ' . $name);
  46292. }
  46293. $this->constraintMap[$name] = $class;
  46294. return $this;
  46295. }
  46296. public function createInstanceFor($constraintName)
  46297. {
  46298. if (!isset($this->constraintMap[$constraintName])) {
  46299. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  46300. }
  46301. if (!isset($this->instanceCache[$constraintName])) {
  46302. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  46303. }
  46304. return clone $this->instanceCache[$constraintName];
  46305. }
  46306. public function getErrorContext()
  46307. {
  46308. return $this->errorContext;
  46309. }
  46310. public function setErrorContext($errorContext)
  46311. {
  46312. $this->errorContext = $errorContext;
  46313. }
  46314. }
  46315. <?php
  46316. namespace JsonSchema\Constraints;
  46317. use JsonSchema\Entity\JsonPointer;
  46318. use JsonSchema\Rfc3339;
  46319. class FormatConstraint extends Constraint
  46320. {
  46321. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  46322. {
  46323. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  46324. return;
  46325. }
  46326. switch ($schema->format) {
  46327. case 'date':
  46328. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  46329. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  46330. }
  46331. break;
  46332. case 'time':
  46333. if (!$this->validateDateTime($element, 'H:i:s')) {
  46334. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  46335. }
  46336. break;
  46337. case 'date-time':
  46338. if (null === Rfc3339::createFromString($element)) {
  46339. $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));
  46340. }
  46341. break;
  46342. case 'utc-millisec':
  46343. if (!$this->validateDateTime($element, 'U')) {
  46344. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  46345. }
  46346. break;
  46347. case 'regex':
  46348. if (!$this->validateRegex($element)) {
  46349. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  46350. }
  46351. break;
  46352. case 'color':
  46353. if (!$this->validateColor($element)) {
  46354. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  46355. }
  46356. break;
  46357. case 'style':
  46358. if (!$this->validateStyle($element)) {
  46359. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  46360. }
  46361. break;
  46362. case 'phone':
  46363. if (!$this->validatePhone($element)) {
  46364. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  46365. }
  46366. break;
  46367. case 'uri':
  46368. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  46369. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  46370. }
  46371. break;
  46372. case 'uriref':
  46373. case 'uri-reference':
  46374. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  46375. if (substr($element, 0, 2) === '//') {
  46376. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  46377. } elseif (substr($element, 0, 1) === '/') {
  46378. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  46379. } elseif (strlen($element)) {
  46380. $pathParts = explode('/', $element, 2);
  46381. if (strpos($pathParts[0], ':') !== false) {
  46382. $validURL = null;
  46383. } else {
  46384. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  46385. }
  46386. } else {
  46387. $validURL = null;
  46388. }
  46389. if ($validURL === null) {
  46390. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  46391. }
  46392. }
  46393. break;
  46394. case 'email':
  46395. $filterFlags = FILTER_NULL_ON_FAILURE;
  46396. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  46397. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  46398. }
  46399. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  46400. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  46401. }
  46402. break;
  46403. case 'ip-address':
  46404. case 'ipv4':
  46405. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  46406. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  46407. }
  46408. break;
  46409. case 'ipv6':
  46410. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  46411. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  46412. }
  46413. break;
  46414. case 'host-name':
  46415. case 'hostname':
  46416. if (!$this->validateHostname($element)) {
  46417. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  46418. }
  46419. break;
  46420. default:
  46421. break;
  46422. }
  46423. }
  46424. protected function validateDateTime($datetime, $format)
  46425. {
  46426. $dt = \DateTime::createFromFormat($format, $datetime);
  46427. if (!$dt) {
  46428. return false;
  46429. }
  46430. if ($datetime === $dt->format($format)) {
  46431. return true;
  46432. }
  46433. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  46434. return true;
  46435. }
  46436. return false;
  46437. }
  46438. protected function validateRegex($regex)
  46439. {
  46440. return false !== @preg_match('/' . $regex . '/u', '');
  46441. }
  46442. protected function validateColor($color)
  46443. {
  46444. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  46445. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  46446. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  46447. return true;
  46448. }
  46449. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  46450. }
  46451. protected function validateStyle($style)
  46452. {
  46453. $properties = explode(';', rtrim($style, ';'));
  46454. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  46455. return empty($invalidEntries);
  46456. }
  46457. protected function validatePhone($phone)
  46458. {
  46459. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  46460. }
  46461. protected function validateHostname($host)
  46462. {
  46463. $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';
  46464. return preg_match($hostnameRegex, $host);
  46465. }
  46466. }
  46467. <?php
  46468. namespace JsonSchema\Constraints;
  46469. use JsonSchema\Entity\JsonPointer;
  46470. class NumberConstraint extends Constraint
  46471. {
  46472. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  46473. {
  46474. if (isset($schema->exclusiveMinimum)) {
  46475. if (isset($schema->minimum)) {
  46476. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  46477. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  46478. } elseif ($element < $schema->minimum) {
  46479. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  46480. }
  46481. } else {
  46482. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  46483. }
  46484. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  46485. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  46486. }
  46487. if (isset($schema->exclusiveMaximum)) {
  46488. if (isset($schema->maximum)) {
  46489. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  46490. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  46491. } elseif ($element > $schema->maximum) {
  46492. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  46493. }
  46494. } else {
  46495. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  46496. }
  46497. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  46498. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  46499. }
  46500. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  46501. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  46502. }
  46503. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  46504. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  46505. }
  46506. $this->checkFormat($element, $schema, $path, $i);
  46507. }
  46508. private function fmod($number1, $number2)
  46509. {
  46510. $modulus = ($number1 - round($number1 / $number2) * $number2);
  46511. $precision = 0.0000000001;
  46512. if (-$precision < $modulus && $modulus < $precision) {
  46513. return 0.0;
  46514. }
  46515. return $modulus;
  46516. }
  46517. }
  46518. <?php
  46519. namespace JsonSchema\Constraints;
  46520. use JsonSchema\Entity\JsonPointer;
  46521. class ObjectConstraint extends Constraint
  46522. {
  46523. protected $appliedDefaults = array();
  46524. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  46525. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  46526. {
  46527. if ($element instanceof UndefinedConstraint) {
  46528. return;
  46529. }
  46530. $this->appliedDefaults = $appliedDefaults;
  46531. $matches = array();
  46532. if ($patternProperties) {
  46533. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  46534. }
  46535. if ($properties) {
  46536. $this->validateProperties($element, $properties, $path);
  46537. }
  46538. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  46539. }
  46540. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  46541. {
  46542. $try = array('/', '#', '+', '~', '%');
  46543. $matches = array();
  46544. foreach ($patternProperties as $pregex => $schema) {
  46545. $delimiter = '/';
  46546. foreach ($try as $delimiter) {
  46547. if (strpos($pregex, $delimiter) === false) {
  46548. break;
  46549. }
  46550. }
  46551. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  46552. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  46553. continue;
  46554. }
  46555. foreach ($element as $i => $value) {
  46556. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  46557. $matches[] = $i;
  46558. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  46559. }
  46560. }
  46561. }
  46562. return $matches;
  46563. }
  46564. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  46565. $properties = null, $additionalProp = null)
  46566. {
  46567. $this->validateMinMaxConstraint($element, $schema, $path);
  46568. foreach ($element as $i => $value) {
  46569. $definition = $this->getProperty($properties, $i);
  46570. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  46571. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  46572. }
  46573. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  46574. if ($additionalProp === true) {
  46575. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  46576. } else {
  46577. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  46578. }
  46579. }
  46580. $require = $this->getProperty($definition, 'requires');
  46581. if ($require && !$this->getProperty($element, $require)) {
  46582. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  46583. }
  46584. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  46585. if (is_object($property)) {
  46586. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  46587. }
  46588. }
  46589. }
  46590. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  46591. {
  46592. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  46593. foreach ($properties as $i => $value) {
  46594. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  46595. $definition = $this->getProperty($properties, $i);
  46596. if (is_object($definition)) {
  46597. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  46598. }
  46599. }
  46600. }
  46601. protected function &getProperty(&$element, $property, $fallback = null)
  46602. {
  46603. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  46604. return $element[$property];
  46605. } elseif (is_object($element) && property_exists($element, $property)) {
  46606. return $element->$property;
  46607. }
  46608. return $fallback;
  46609. }
  46610. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  46611. {
  46612. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  46613. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  46614. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  46615. }
  46616. }
  46617. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  46618. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  46619. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  46620. }
  46621. }
  46622. }
  46623. }
  46624. <?php
  46625. namespace JsonSchema\Constraints;
  46626. use JsonSchema\Entity\JsonPointer;
  46627. use JsonSchema\Exception\InvalidArgumentException;
  46628. use JsonSchema\Exception\InvalidSchemaException;
  46629. use JsonSchema\Exception\RuntimeException;
  46630. use JsonSchema\Validator;
  46631. class SchemaConstraint extends Constraint
  46632. {
  46633. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  46634. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  46635. {
  46636. if ($schema !== null) {
  46637. $validationSchema = $schema;
  46638. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  46639. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  46640. } else {
  46641. throw new InvalidArgumentException('no schema found to verify against');
  46642. }
  46643. if (is_array($validationSchema)) {
  46644. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  46645. }
  46646. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  46647. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  46648. throw new RuntimeException('Cannot validate the schema of a non-object');
  46649. }
  46650. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  46651. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  46652. } else {
  46653. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  46654. }
  46655. $schemaStorage = $this->factory->getSchemaStorage();
  46656. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  46657. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  46658. }
  46659. $initialErrorCount = $this->numErrors();
  46660. $initialConfig = $this->factory->getConfig();
  46661. $initialContext = $this->factory->getErrorContext();
  46662. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  46663. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  46664. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  46665. try {
  46666. $this->check($validationSchema, $schemaSpec);
  46667. } catch (\Exception $e) {
  46668. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  46669. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  46670. }
  46671. }
  46672. if ($this->numErrors() > $initialErrorCount) {
  46673. $this->addError($path, 'Schema is not valid', 'schema');
  46674. }
  46675. $this->factory->setConfig($initialConfig);
  46676. $this->factory->setErrorContext($initialContext);
  46677. }
  46678. $this->checkUndefined($element, $validationSchema, $path, $i);
  46679. }
  46680. }
  46681. <?php
  46682. namespace JsonSchema\Constraints;
  46683. use JsonSchema\Entity\JsonPointer;
  46684. class StringConstraint extends Constraint
  46685. {
  46686. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  46687. {
  46688. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  46689. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  46690. 'maxLength' => $schema->maxLength,
  46691. ));
  46692. }
  46693. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  46694. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  46695. 'minLength' => $schema->minLength,
  46696. ));
  46697. }
  46698. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  46699. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  46700. 'pattern' => $schema->pattern,
  46701. ));
  46702. }
  46703. $this->checkFormat($element, $schema, $path, $i);
  46704. }
  46705. private function strlen($string)
  46706. {
  46707. if (extension_loaded('mbstring')) {
  46708. return mb_strlen($string, mb_detect_encoding($string));
  46709. }
  46710. return strlen($string);
  46711. }
  46712. }
  46713. <?php
  46714. namespace JsonSchema\Constraints\TypeCheck;
  46715. class LooseTypeCheck implements TypeCheckInterface
  46716. {
  46717. public static function isObject($value)
  46718. {
  46719. return
  46720. is_object($value) ||
  46721. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  46722. }
  46723. public static function isArray($value)
  46724. {
  46725. return
  46726. is_array($value) &&
  46727. (count($value) == 0 || !self::isAssociativeArray($value));
  46728. }
  46729. public static function propertyGet($value, $property)
  46730. {
  46731. if (is_object($value)) {
  46732. return $value->{$property};
  46733. }
  46734. return $value[$property];
  46735. }
  46736. public static function propertySet(&$value, $property, $data)
  46737. {
  46738. if (is_object($value)) {
  46739. $value->{$property} = $data;
  46740. } else {
  46741. $value[$property] = $data;
  46742. }
  46743. }
  46744. public static function propertyExists($value, $property)
  46745. {
  46746. if (is_object($value)) {
  46747. return property_exists($value, $property);
  46748. }
  46749. return array_key_exists($property, $value);
  46750. }
  46751. public static function propertyCount($value)
  46752. {
  46753. if (is_object($value)) {
  46754. return count(get_object_vars($value));
  46755. }
  46756. return count($value);
  46757. }
  46758. private static function isAssociativeArray($arr)
  46759. {
  46760. return array_keys($arr) !== range(0, count($arr) - 1);
  46761. }
  46762. }
  46763. <?php
  46764. namespace JsonSchema\Constraints\TypeCheck;
  46765. class StrictTypeCheck implements TypeCheckInterface
  46766. {
  46767. public static function isObject($value)
  46768. {
  46769. return is_object($value);
  46770. }
  46771. public static function isArray($value)
  46772. {
  46773. return is_array($value);
  46774. }
  46775. public static function propertyGet($value, $property)
  46776. {
  46777. return $value->{$property};
  46778. }
  46779. public static function propertySet(&$value, $property, $data)
  46780. {
  46781. $value->{$property} = $data;
  46782. }
  46783. public static function propertyExists($value, $property)
  46784. {
  46785. return property_exists($value, $property);
  46786. }
  46787. public static function propertyCount($value)
  46788. {
  46789. if (!is_object($value)) {
  46790. return 0;
  46791. }
  46792. return count(get_object_vars($value));
  46793. }
  46794. }
  46795. <?php
  46796. namespace JsonSchema\Constraints\TypeCheck;
  46797. interface TypeCheckInterface
  46798. {
  46799. public static function isObject($value);
  46800. public static function isArray($value);
  46801. public static function propertyGet($value, $property);
  46802. public static function propertySet(&$value, $property, $data);
  46803. public static function propertyExists($value, $property);
  46804. public static function propertyCount($value);
  46805. }
  46806. <?php
  46807. namespace JsonSchema\Constraints;
  46808. use JsonSchema\Entity\JsonPointer;
  46809. use JsonSchema\Exception\InvalidArgumentException;
  46810. use UnexpectedValueException as StandardUnexpectedValueException;
  46811. class TypeConstraint extends Constraint
  46812. {
  46813. public static $wording = array(
  46814. 'integer' => 'an integer',
  46815. 'number' => 'a number',
  46816. 'boolean' => 'a boolean',
  46817. 'object' => 'an object',
  46818. 'array' => 'an array',
  46819. 'string' => 'a string',
  46820. 'null' => 'a null',
  46821. 'any' => null,
  46822. 0 => null,
  46823. );
  46824. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  46825. {
  46826. $type = isset($schema->type) ? $schema->type : null;
  46827. $isValid = false;
  46828. $wording = array();
  46829. if (is_array($type)) {
  46830. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  46831. } elseif (is_object($type)) {
  46832. $this->checkUndefined($value, $type, $path);
  46833. return;
  46834. } else {
  46835. $isValid = $this->validateType($value, $type);
  46836. }
  46837. if ($isValid === false) {
  46838. if (!is_array($type)) {
  46839. $this->validateTypeNameWording($type);
  46840. $wording[] = self::$wording[$type];
  46841. }
  46842. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  46843. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  46844. }
  46845. }
  46846. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  46847. {
  46848. foreach ($type as $tp) {
  46849. if (is_object($tp)) {
  46850. if (!$isValid) {
  46851. $validator = $this->factory->createInstanceFor('type');
  46852. $subSchema = new \stdClass();
  46853. $subSchema->type = $tp;
  46854. $validator->check($value, $subSchema, $path, null);
  46855. $error = $validator->getErrors();
  46856. $isValid = !(bool) $error;
  46857. $validTypesWording[] = self::$wording['object'];
  46858. }
  46859. } else {
  46860. $this->validateTypeNameWording($tp);
  46861. $validTypesWording[] = self::$wording[$tp];
  46862. if (!$isValid) {
  46863. $isValid = $this->validateType($value, $tp);
  46864. }
  46865. }
  46866. }
  46867. }
  46868. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  46869. {
  46870. if ($listEnd === false || !isset($elements[1])) {
  46871. return implode($delimiter, $elements);
  46872. }
  46873. $lastElement = array_slice($elements, -1);
  46874. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  46875. $implodedElements = array_merge(array($firsElements), $lastElement);
  46876. return join(" $listEnd ", $implodedElements);
  46877. }
  46878. protected function validateTypeNameWording($type)
  46879. {
  46880. if (!isset(self::$wording[$type])) {
  46881. throw new StandardUnexpectedValueException(
  46882. sprintf(
  46883. 'No wording for %s available, expected wordings are: [%s]',
  46884. var_export($type, true),
  46885. implode(', ', array_filter(self::$wording)))
  46886. );
  46887. }
  46888. }
  46889. protected function validateType(&$value, $type)
  46890. {
  46891. if (!$type) {
  46892. return true;
  46893. }
  46894. if ('any' === $type) {
  46895. return true;
  46896. }
  46897. if ('object' === $type) {
  46898. return $this->getTypeCheck()->isObject($value);
  46899. }
  46900. if ('array' === $type) {
  46901. return $this->getTypeCheck()->isArray($value);
  46902. }
  46903. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  46904. if ('integer' === $type) {
  46905. if ($coerce) {
  46906. $value = $this->toInteger($value);
  46907. }
  46908. return is_int($value);
  46909. }
  46910. if ('number' === $type) {
  46911. if ($coerce) {
  46912. $value = $this->toNumber($value);
  46913. }
  46914. return is_numeric($value) && !is_string($value);
  46915. }
  46916. if ('boolean' === $type) {
  46917. if ($coerce) {
  46918. $value = $this->toBoolean($value);
  46919. }
  46920. return is_bool($value);
  46921. }
  46922. if ('string' === $type) {
  46923. return is_string($value);
  46924. }
  46925. if ('email' === $type) {
  46926. return is_string($value);
  46927. }
  46928. if ('null' === $type) {
  46929. return is_null($value);
  46930. }
  46931. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  46932. }
  46933. protected function toBoolean($value)
  46934. {
  46935. if ($value === 'true') {
  46936. return true;
  46937. }
  46938. if ($value === 'false') {
  46939. return false;
  46940. }
  46941. return $value;
  46942. }
  46943. protected function toNumber($value)
  46944. {
  46945. if (is_numeric($value)) {
  46946. return $value + 0;
  46947. }
  46948. return $value;
  46949. }
  46950. protected function toInteger($value)
  46951. {
  46952. if (is_numeric($value) && (int) $value == $value) {
  46953. return (int) $value;
  46954. }
  46955. return $value;
  46956. }
  46957. }
  46958. <?php
  46959. namespace JsonSchema\Constraints;
  46960. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  46961. use JsonSchema\Entity\JsonPointer;
  46962. use JsonSchema\Exception\ValidationException;
  46963. use JsonSchema\Uri\UriResolver;
  46964. class UndefinedConstraint extends Constraint
  46965. {
  46966. protected $appliedDefaults = array();
  46967. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  46968. {
  46969. if (is_null($schema) || !is_object($schema)) {
  46970. return;
  46971. }
  46972. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  46973. if ($fromDefault) {
  46974. $path->setFromDefault();
  46975. }
  46976. $this->validateCommonProperties($value, $schema, $path, $i);
  46977. $this->validateOfProperties($value, $schema, $path, '');
  46978. $this->validateTypes($value, $schema, $path, $i);
  46979. }
  46980. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  46981. {
  46982. if ($this->getTypeCheck()->isArray($value)) {
  46983. $this->checkArray($value, $schema, $path, $i);
  46984. }
  46985. if (LooseTypeCheck::isObject($value)) {
  46986. $this->checkObject(
  46987. $value,
  46988. $schema,
  46989. $path,
  46990. isset($schema->properties) ? $schema->properties : null,
  46991. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  46992. isset($schema->patternProperties) ? $schema->patternProperties : null,
  46993. $this->appliedDefaults
  46994. );
  46995. }
  46996. if (is_string($value)) {
  46997. $this->checkString($value, $schema, $path, $i);
  46998. }
  46999. if (is_numeric($value)) {
  47000. $this->checkNumber($value, $schema, $path, $i);
  47001. }
  47002. if (isset($schema->enum)) {
  47003. $this->checkEnum($value, $schema, $path, $i);
  47004. }
  47005. }
  47006. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  47007. {
  47008. if (isset($schema->extends)) {
  47009. if (is_string($schema->extends)) {
  47010. $schema->extends = $this->validateUri($schema, $schema->extends);
  47011. }
  47012. if (is_array($schema->extends)) {
  47013. foreach ($schema->extends as $extends) {
  47014. $this->checkUndefined($value, $extends, $path, $i);
  47015. }
  47016. } else {
  47017. $this->checkUndefined($value, $schema->extends, $path, $i);
  47018. }
  47019. }
  47020. if (!$path->fromDefault()) {
  47021. $this->applyDefaultValues($value, $schema, $path);
  47022. }
  47023. if ($this->getTypeCheck()->isObject($value)) {
  47024. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  47025. foreach ($schema->required as $required) {
  47026. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  47027. $this->addError(
  47028. $this->incrementPath($path ?: new JsonPointer(''), $required),
  47029. 'The property ' . $required . ' is required',
  47030. 'required'
  47031. );
  47032. }
  47033. }
  47034. } elseif (isset($schema->required) && !is_array($schema->required)) {
  47035. if ($schema->required && $value instanceof self) {
  47036. $propertyPaths = $path->getPropertyPaths();
  47037. $propertyName = end($propertyPaths);
  47038. $this->addError(
  47039. $path,
  47040. 'The property ' . $propertyName . ' is required',
  47041. 'required'
  47042. );
  47043. }
  47044. } else {
  47045. if ($value instanceof self) {
  47046. return;
  47047. }
  47048. }
  47049. }
  47050. if (!($value instanceof self)) {
  47051. $this->checkType($value, $schema, $path, $i);
  47052. }
  47053. if (isset($schema->disallow)) {
  47054. $initErrors = $this->getErrors();
  47055. $typeSchema = new \stdClass();
  47056. $typeSchema->type = $schema->disallow;
  47057. $this->checkType($value, $typeSchema, $path);
  47058. if (count($this->getErrors()) == count($initErrors)) {
  47059. $this->addError($path, 'Disallowed value was matched', 'disallow');
  47060. } else {
  47061. $this->errors = $initErrors;
  47062. }
  47063. }
  47064. if (isset($schema->not)) {
  47065. $initErrors = $this->getErrors();
  47066. $this->checkUndefined($value, $schema->not, $path, $i);
  47067. if (count($this->getErrors()) == count($initErrors)) {
  47068. $this->addError($path, 'Matched a schema which it should not', 'not');
  47069. } else {
  47070. $this->errors = $initErrors;
  47071. }
  47072. }
  47073. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  47074. $this->validateDependencies($value, $schema->dependencies, $path);
  47075. }
  47076. }
  47077. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  47078. {
  47079. if (!$requiredOnly) {
  47080. return true;
  47081. }
  47082. if (
  47083. $name !== null
  47084. && isset($parentSchema->required)
  47085. && is_array($parentSchema->required)
  47086. && in_array($name, $parentSchema->required)
  47087. ) {
  47088. return true;
  47089. }
  47090. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  47091. return true;
  47092. }
  47093. return false;
  47094. }
  47095. protected function applyDefaultValues(&$value, $schema, $path)
  47096. {
  47097. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  47098. return;
  47099. }
  47100. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  47101. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  47102. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  47103. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  47104. if (
  47105. !LooseTypeCheck::propertyExists($value, $currentProperty)
  47106. && property_exists($propertyDefinition, 'default')
  47107. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  47108. ) {
  47109. if (is_object($propertyDefinition->default)) {
  47110. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  47111. } else {
  47112. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  47113. }
  47114. $this->appliedDefaults[] = $currentProperty;
  47115. }
  47116. }
  47117. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  47118. $items = array();
  47119. if (LooseTypeCheck::isArray($schema->items)) {
  47120. $items = $schema->items;
  47121. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  47122. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  47123. }
  47124. foreach ($items as $currentItem => $itemDefinition) {
  47125. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  47126. if (
  47127. !array_key_exists($currentItem, $value)
  47128. && property_exists($itemDefinition, 'default')
  47129. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  47130. if (is_object($itemDefinition->default)) {
  47131. $value[$currentItem] = clone $itemDefinition->default;
  47132. } else {
  47133. $value[$currentItem] = $itemDefinition->default;
  47134. }
  47135. }
  47136. $path->setFromDefault();
  47137. }
  47138. } elseif (
  47139. $value instanceof self
  47140. && property_exists($schema, 'default')
  47141. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  47142. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  47143. $path->setFromDefault();
  47144. }
  47145. }
  47146. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  47147. {
  47148. if ($value instanceof self) {
  47149. return;
  47150. }
  47151. if (isset($schema->allOf)) {
  47152. $isValid = true;
  47153. foreach ($schema->allOf as $allOf) {
  47154. $initErrors = $this->getErrors();
  47155. $this->checkUndefined($value, $allOf, $path, $i);
  47156. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  47157. }
  47158. if (!$isValid) {
  47159. $this->addError($path, 'Failed to match all schemas', 'allOf');
  47160. }
  47161. }
  47162. if (isset($schema->anyOf)) {
  47163. $isValid = false;
  47164. $startErrors = $this->getErrors();
  47165. $caughtException = null;
  47166. foreach ($schema->anyOf as $anyOf) {
  47167. $initErrors = $this->getErrors();
  47168. try {
  47169. $this->checkUndefined($value, $anyOf, $path, $i);
  47170. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  47171. break;
  47172. }
  47173. } catch (ValidationException $e) {
  47174. $isValid = false;
  47175. }
  47176. }
  47177. if (!$isValid) {
  47178. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  47179. } else {
  47180. $this->errors = $startErrors;
  47181. }
  47182. }
  47183. if (isset($schema->oneOf)) {
  47184. $allErrors = array();
  47185. $matchedSchemas = 0;
  47186. $startErrors = $this->getErrors();
  47187. foreach ($schema->oneOf as $oneOf) {
  47188. try {
  47189. $this->errors = array();
  47190. $this->checkUndefined($value, $oneOf, $path, $i);
  47191. if (count($this->getErrors()) == 0) {
  47192. $matchedSchemas++;
  47193. }
  47194. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  47195. } catch (ValidationException $e) {
  47196. }
  47197. }
  47198. if ($matchedSchemas !== 1) {
  47199. $this->addErrors(array_merge($allErrors, $startErrors));
  47200. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  47201. } else {
  47202. $this->errors = $startErrors;
  47203. }
  47204. }
  47205. }
  47206. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  47207. {
  47208. foreach ($dependencies as $key => $dependency) {
  47209. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  47210. if (is_string($dependency)) {
  47211. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  47212. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  47213. }
  47214. } elseif (is_array($dependency)) {
  47215. foreach ($dependency as $d) {
  47216. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  47217. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  47218. }
  47219. }
  47220. } elseif (is_object($dependency)) {
  47221. $this->checkUndefined($value, $dependency, $path, $i);
  47222. }
  47223. }
  47224. }
  47225. }
  47226. protected function validateUri($schema, $schemaUri = null)
  47227. {
  47228. $resolver = new UriResolver();
  47229. $retriever = $this->factory->getUriRetriever();
  47230. $jsonSchema = null;
  47231. if ($resolver->isValid($schemaUri)) {
  47232. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  47233. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  47234. }
  47235. return $jsonSchema;
  47236. }
  47237. }
  47238. <?php
  47239. namespace JsonSchema\Entity;
  47240. use JsonSchema\Exception\InvalidArgumentException;
  47241. class JsonPointer
  47242. {
  47243. private $filename;
  47244. private $propertyPaths = array();
  47245. private $fromDefault = false;
  47246. public function __construct($value)
  47247. {
  47248. if (!is_string($value)) {
  47249. throw new InvalidArgumentException('Ref value must be a string');
  47250. }
  47251. $splitRef = explode('#', $value, 2);
  47252. $this->filename = $splitRef[0];
  47253. if (array_key_exists(1, $splitRef)) {
  47254. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  47255. }
  47256. }
  47257. private function decodePropertyPaths($propertyPathString)
  47258. {
  47259. $paths = array();
  47260. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  47261. $path = $this->decodePath($path);
  47262. if (is_string($path) && '' !== $path) {
  47263. $paths[] = $path;
  47264. }
  47265. }
  47266. return $paths;
  47267. }
  47268. private function encodePropertyPaths()
  47269. {
  47270. return array_map(
  47271. array($this, 'encodePath'),
  47272. $this->getPropertyPaths()
  47273. );
  47274. }
  47275. private function decodePath($path)
  47276. {
  47277. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  47278. }
  47279. private function encodePath($path)
  47280. {
  47281. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  47282. }
  47283. public function getFilename()
  47284. {
  47285. return $this->filename;
  47286. }
  47287. public function getPropertyPaths()
  47288. {
  47289. return $this->propertyPaths;
  47290. }
  47291. public function withPropertyPaths(array $propertyPaths)
  47292. {
  47293. $new = clone $this;
  47294. $new->propertyPaths = $propertyPaths;
  47295. return $new;
  47296. }
  47297. public function getPropertyPathAsString()
  47298. {
  47299. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  47300. }
  47301. public function __toString()
  47302. {
  47303. return $this->getFilename() . $this->getPropertyPathAsString();
  47304. }
  47305. public function setFromDefault()
  47306. {
  47307. $this->fromDefault = true;
  47308. }
  47309. public function fromDefault()
  47310. {
  47311. return $this->fromDefault;
  47312. }
  47313. }
  47314. <?php
  47315. namespace JsonSchema\Exception;
  47316. interface ExceptionInterface
  47317. {
  47318. }
  47319. <?php
  47320. namespace JsonSchema\Exception;
  47321. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  47322. {
  47323. }
  47324. <?php
  47325. namespace JsonSchema\Exception;
  47326. class InvalidConfigException extends RuntimeException
  47327. {
  47328. }
  47329. <?php
  47330. namespace JsonSchema\Exception;
  47331. class InvalidSchemaException extends RuntimeException
  47332. {
  47333. }
  47334. <?php
  47335. namespace JsonSchema\Exception;
  47336. class InvalidSchemaMediaTypeException extends RuntimeException
  47337. {
  47338. }
  47339. <?php
  47340. namespace JsonSchema\Exception;
  47341. class InvalidSourceUriException extends InvalidArgumentException
  47342. {
  47343. }
  47344. <?php
  47345. namespace JsonSchema\Exception;
  47346. class JsonDecodingException extends RuntimeException
  47347. {
  47348. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  47349. {
  47350. switch ($code) {
  47351. case JSON_ERROR_DEPTH:
  47352. $message = 'The maximum stack depth has been exceeded';
  47353. break;
  47354. case JSON_ERROR_STATE_MISMATCH:
  47355. $message = 'Invalid or malformed JSON';
  47356. break;
  47357. case JSON_ERROR_CTRL_CHAR:
  47358. $message = 'Control character error, possibly incorrectly encoded';
  47359. break;
  47360. case JSON_ERROR_UTF8:
  47361. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  47362. break;
  47363. case JSON_ERROR_SYNTAX:
  47364. $message = 'JSON syntax is malformed';
  47365. break;
  47366. default:
  47367. $message = 'Syntax error';
  47368. }
  47369. parent::__construct($message, $code, $previous);
  47370. }
  47371. }
  47372. <?php
  47373. namespace JsonSchema\Exception;
  47374. class ResourceNotFoundException extends RuntimeException
  47375. {
  47376. }
  47377. <?php
  47378. namespace JsonSchema\Exception;
  47379. class RuntimeException extends \RuntimeException implements ExceptionInterface
  47380. {
  47381. }
  47382. <?php
  47383. namespace JsonSchema\Exception;
  47384. class UnresolvableJsonPointerException extends InvalidArgumentException
  47385. {
  47386. }
  47387. <?php
  47388. namespace JsonSchema\Exception;
  47389. class UriResolverException extends RuntimeException
  47390. {
  47391. }
  47392. <?php
  47393. namespace JsonSchema\Exception;
  47394. class ValidationException extends RuntimeException
  47395. {
  47396. }
  47397. <?php
  47398. namespace JsonSchema\Iterator;
  47399. class ObjectIterator implements \Iterator, \Countable
  47400. {
  47401. private $object;
  47402. private $position = 0;
  47403. private $data = array();
  47404. private $initialized = false;
  47405. public function __construct($object)
  47406. {
  47407. $this->object = $object;
  47408. }
  47409. public function current()
  47410. {
  47411. $this->initialize();
  47412. return $this->data[$this->position];
  47413. }
  47414. public function next()
  47415. {
  47416. $this->initialize();
  47417. $this->position++;
  47418. }
  47419. public function key()
  47420. {
  47421. $this->initialize();
  47422. return $this->position;
  47423. }
  47424. public function valid()
  47425. {
  47426. $this->initialize();
  47427. return isset($this->data[$this->position]);
  47428. }
  47429. public function rewind()
  47430. {
  47431. $this->initialize();
  47432. $this->position = 0;
  47433. }
  47434. public function count()
  47435. {
  47436. $this->initialize();
  47437. return count($this->data);
  47438. }
  47439. private function initialize()
  47440. {
  47441. if (!$this->initialized) {
  47442. $this->data = $this->buildDataFromObject($this->object);
  47443. $this->initialized = true;
  47444. }
  47445. }
  47446. private function buildDataFromObject($object)
  47447. {
  47448. $result = array();
  47449. $stack = new \SplStack();
  47450. $stack->push($object);
  47451. while (!$stack->isEmpty()) {
  47452. $current = $stack->pop();
  47453. if (is_object($current)) {
  47454. array_push($result, $current);
  47455. }
  47456. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  47457. if (is_object($propertyValue) || is_array($propertyValue)) {
  47458. $stack->push($propertyValue);
  47459. }
  47460. }
  47461. }
  47462. return $result;
  47463. }
  47464. private function getDataFromItem($item)
  47465. {
  47466. if (!is_object($item) && !is_array($item)) {
  47467. return array();
  47468. }
  47469. return is_object($item) ? get_object_vars($item) : $item;
  47470. }
  47471. }
  47472. <?php
  47473. namespace JsonSchema;
  47474. class Rfc3339
  47475. {
  47476. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  47477. public static function createFromString($string)
  47478. {
  47479. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  47480. return null;
  47481. }
  47482. $dateAndTime = $matches[1];
  47483. $microseconds = $matches[2] ?: '.000000';
  47484. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  47485. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  47486. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  47487. return $dateTime ?: null;
  47488. }
  47489. }
  47490. <?php
  47491. namespace JsonSchema;
  47492. use JsonSchema\Constraints\BaseConstraint;
  47493. use JsonSchema\Entity\JsonPointer;
  47494. use JsonSchema\Exception\UnresolvableJsonPointerException;
  47495. use JsonSchema\Uri\UriResolver;
  47496. use JsonSchema\Uri\UriRetriever;
  47497. class SchemaStorage implements SchemaStorageInterface
  47498. {
  47499. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  47500. protected $uriRetriever;
  47501. protected $uriResolver;
  47502. protected $schemas = array();
  47503. public function __construct(
  47504. UriRetrieverInterface $uriRetriever = null,
  47505. UriResolverInterface $uriResolver = null
  47506. ) {
  47507. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  47508. $this->uriResolver = $uriResolver ?: new UriResolver();
  47509. }
  47510. public function getUriRetriever()
  47511. {
  47512. return $this->uriRetriever;
  47513. }
  47514. public function getUriResolver()
  47515. {
  47516. return $this->uriResolver;
  47517. }
  47518. public function addSchema($id, $schema = null)
  47519. {
  47520. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  47521. $schema = $this->uriRetriever->retrieve($id);
  47522. }
  47523. if (is_array($schema)) {
  47524. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  47525. }
  47526. if (is_object($schema) && property_exists($schema, 'id')) {
  47527. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  47528. $schema->properties->id->format = 'uri-reference';
  47529. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  47530. $schema->properties->id->format = 'uri-reference';
  47531. $schema->properties->{'$ref'}->format = 'uri-reference';
  47532. }
  47533. }
  47534. $this->expandRefs($schema, $id);
  47535. $this->schemas[$id] = $schema;
  47536. }
  47537. private function expandRefs(&$schema, $base = null)
  47538. {
  47539. if (!is_object($schema)) {
  47540. if (is_array($schema)) {
  47541. foreach ($schema as &$member) {
  47542. $this->expandRefs($member, $base);
  47543. }
  47544. }
  47545. return;
  47546. }
  47547. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  47548. $base = $this->uriResolver->resolve($schema->id, $base);
  47549. }
  47550. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  47551. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  47552. $schema->{'$ref'} = (string) $refPointer;
  47553. }
  47554. foreach ($schema as &$member) {
  47555. $this->expandRefs($member, $base);
  47556. }
  47557. }
  47558. public function getSchema($id)
  47559. {
  47560. if (!array_key_exists($id, $this->schemas)) {
  47561. $this->addSchema($id);
  47562. }
  47563. return $this->schemas[$id];
  47564. }
  47565. public function resolveRef($ref)
  47566. {
  47567. $jsonPointer = new JsonPointer($ref);
  47568. $fileName = $jsonPointer->getFilename();
  47569. if (!strlen($fileName)) {
  47570. throw new UnresolvableJsonPointerException(sprintf(
  47571. "Could not resolve fragment '%s': no file is defined",
  47572. $jsonPointer->getPropertyPathAsString()
  47573. ));
  47574. }
  47575. $refSchema = $this->getSchema($fileName);
  47576. foreach ($jsonPointer->getPropertyPaths() as $path) {
  47577. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  47578. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  47579. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  47580. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  47581. } else {
  47582. throw new UnresolvableJsonPointerException(sprintf(
  47583. 'File: %s is found, but could not resolve fragment: %s',
  47584. $jsonPointer->getFilename(),
  47585. $jsonPointer->getPropertyPathAsString()
  47586. ));
  47587. }
  47588. }
  47589. return $refSchema;
  47590. }
  47591. public function resolveRefSchema($refSchema)
  47592. {
  47593. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  47594. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  47595. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  47596. unset($refSchema->{'$ref'});
  47597. }
  47598. return $refSchema;
  47599. }
  47600. }
  47601. <?php
  47602. namespace JsonSchema;
  47603. interface SchemaStorageInterface
  47604. {
  47605. public function addSchema($id, $schema = null);
  47606. public function getSchema($id);
  47607. public function resolveRef($ref);
  47608. public function resolveRefSchema($refSchema);
  47609. }
  47610. <?php
  47611. namespace JsonSchema\Uri\Retrievers;
  47612. abstract class AbstractRetriever implements UriRetrieverInterface
  47613. {
  47614. protected $contentType;
  47615. public function getContentType()
  47616. {
  47617. return $this->contentType;
  47618. }
  47619. }
  47620. <?php
  47621. namespace JsonSchema\Uri\Retrievers;
  47622. use JsonSchema\Exception\RuntimeException;
  47623. use JsonSchema\Validator;
  47624. class Curl extends AbstractRetriever
  47625. {
  47626. protected $messageBody;
  47627. public function __construct()
  47628. {
  47629. if (!function_exists('curl_init')) {
  47630. throw new RuntimeException('cURL not installed');
  47631. }
  47632. }
  47633. public function retrieve($uri)
  47634. {
  47635. $ch = curl_init();
  47636. curl_setopt($ch, CURLOPT_URL, $uri);
  47637. curl_setopt($ch, CURLOPT_HEADER, true);
  47638. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  47639. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  47640. $response = curl_exec($ch);
  47641. if (false === $response) {
  47642. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  47643. }
  47644. $this->fetchMessageBody($response);
  47645. $this->fetchContentType($response);
  47646. curl_close($ch);
  47647. return $this->messageBody;
  47648. }
  47649. private function fetchMessageBody($response)
  47650. {
  47651. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  47652. $this->messageBody = $match[1];
  47653. }
  47654. protected function fetchContentType($response)
  47655. {
  47656. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  47657. $this->contentType = trim($match[1]);
  47658. return true;
  47659. }
  47660. return false;
  47661. }
  47662. }
  47663. <?php
  47664. namespace JsonSchema\Uri\Retrievers;
  47665. use JsonSchema\Exception\ResourceNotFoundException;
  47666. class FileGetContents extends AbstractRetriever
  47667. {
  47668. protected $messageBody;
  47669. public function retrieve($uri)
  47670. {
  47671. $errorMessage = null;
  47672. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  47673. $errorMessage = $errstr;
  47674. });
  47675. $response = file_get_contents($uri);
  47676. restore_error_handler();
  47677. if ($errorMessage) {
  47678. throw new ResourceNotFoundException($errorMessage);
  47679. }
  47680. if (false === $response) {
  47681. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  47682. }
  47683. if ($response == ''
  47684. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  47685. ) {
  47686. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  47687. }
  47688. $this->messageBody = $response;
  47689. if (!empty($http_response_header)) {
  47690. $this->fetchContentType($http_response_header);
  47691. } else {
  47692. $this->contentType = null;
  47693. }
  47694. return $this->messageBody;
  47695. }
  47696. private function fetchContentType(array $headers)
  47697. {
  47698. foreach ($headers as $header) {
  47699. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  47700. return true;
  47701. }
  47702. }
  47703. return false;
  47704. }
  47705. protected static function getContentTypeMatchInHeader($header)
  47706. {
  47707. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  47708. return trim($match[1]);
  47709. }
  47710. return null;
  47711. }
  47712. }
  47713. <?php
  47714. namespace JsonSchema\Uri\Retrievers;
  47715. use JsonSchema\Validator;
  47716. class PredefinedArray extends AbstractRetriever
  47717. {
  47718. private $schemas;
  47719. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  47720. {
  47721. $this->schemas = $schemas;
  47722. $this->contentType = $contentType;
  47723. }
  47724. public function retrieve($uri)
  47725. {
  47726. if (!array_key_exists($uri, $this->schemas)) {
  47727. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  47728. 'The JSON schema "%s" was not found.',
  47729. $uri
  47730. ));
  47731. }
  47732. return $this->schemas[$uri];
  47733. }
  47734. }
  47735. <?php
  47736. namespace JsonSchema\Uri\Retrievers;
  47737. interface UriRetrieverInterface
  47738. {
  47739. public function retrieve($uri);
  47740. public function getContentType();
  47741. }
  47742. <?php
  47743. namespace JsonSchema\Uri;
  47744. use JsonSchema\Exception\UriResolverException;
  47745. use JsonSchema\UriResolverInterface;
  47746. class UriResolver implements UriResolverInterface
  47747. {
  47748. public function parse($uri)
  47749. {
  47750. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  47751. $components = array();
  47752. if (5 < count($match)) {
  47753. $components = array(
  47754. 'scheme' => $match[2],
  47755. 'authority' => $match[4],
  47756. 'path' => $match[5]
  47757. );
  47758. }
  47759. if (7 < count($match)) {
  47760. $components['query'] = $match[7];
  47761. }
  47762. if (9 < count($match)) {
  47763. $components['fragment'] = $match[9];
  47764. }
  47765. return $components;
  47766. }
  47767. public function generate(array $components)
  47768. {
  47769. $uri = $components['scheme'] . '://'
  47770. . $components['authority']
  47771. . $components['path'];
  47772. if (array_key_exists('query', $components) && strlen($components['query'])) {
  47773. $uri .= '?' . $components['query'];
  47774. }
  47775. if (array_key_exists('fragment', $components)) {
  47776. $uri .= '#' . $components['fragment'];
  47777. }
  47778. return $uri;
  47779. }
  47780. public function resolve($uri, $baseUri = null)
  47781. {
  47782. if (
  47783. !is_null($baseUri) &&
  47784. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  47785. !preg_match('|^[^/]+://|u', $baseUri)
  47786. ) {
  47787. if (is_file($baseUri)) {
  47788. $baseUri = 'file://' . realpath($baseUri);
  47789. } elseif (is_dir($baseUri)) {
  47790. $baseUri = 'file://' . realpath($baseUri) . '/';
  47791. } else {
  47792. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  47793. }
  47794. }
  47795. if ($uri == '') {
  47796. return $baseUri;
  47797. }
  47798. $components = $this->parse($uri);
  47799. $path = $components['path'];
  47800. if (!empty($components['scheme'])) {
  47801. return $uri;
  47802. }
  47803. $baseComponents = $this->parse($baseUri);
  47804. $basePath = $baseComponents['path'];
  47805. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  47806. if (isset($components['fragment'])) {
  47807. $baseComponents['fragment'] = $components['fragment'];
  47808. }
  47809. return $this->generate($baseComponents);
  47810. }
  47811. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  47812. {
  47813. $relativePath = self::normalizePath($relativePath);
  47814. if ($relativePath == '') {
  47815. return $basePath;
  47816. }
  47817. if ($relativePath[0] == '/') {
  47818. return $relativePath;
  47819. }
  47820. $basePathSegments = explode('/', $basePath);
  47821. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  47822. $numLevelUp = strlen($match[0]) /3 + 1;
  47823. if ($numLevelUp >= count($basePathSegments)) {
  47824. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  47825. }
  47826. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  47827. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  47828. return implode('/', $basePathSegments) . '/' . $path;
  47829. }
  47830. private static function normalizePath($path)
  47831. {
  47832. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  47833. $path = preg_replace('|//|', '/', $path);
  47834. return $path;
  47835. }
  47836. public function isValid($uri)
  47837. {
  47838. $components = $this->parse($uri);
  47839. return !empty($components);
  47840. }
  47841. }
  47842. <?php
  47843. namespace JsonSchema\Uri;
  47844. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  47845. use JsonSchema\Exception\JsonDecodingException;
  47846. use JsonSchema\Exception\ResourceNotFoundException;
  47847. use JsonSchema\Uri\Retrievers\FileGetContents;
  47848. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  47849. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  47850. use JsonSchema\Validator;
  47851. class UriRetriever implements BaseUriRetrieverInterface
  47852. {
  47853. protected $translationMap = array(
  47854. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  47855. );
  47856. protected $allowedInvalidContentTypeEndpoints = array(
  47857. 'http://json-schema.org/',
  47858. 'https://json-schema.org/'
  47859. );
  47860. protected $uriRetriever = null;
  47861. private $schemaCache = array();
  47862. public function addInvalidContentTypeEndpoint($endpoint)
  47863. {
  47864. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  47865. }
  47866. public function confirmMediaType($uriRetriever, $uri)
  47867. {
  47868. $contentType = $uriRetriever->getContentType();
  47869. if (is_null($contentType)) {
  47870. return;
  47871. }
  47872. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  47873. return;
  47874. }
  47875. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  47876. if (strpos($uri, $endpoint) === 0) {
  47877. return true;
  47878. }
  47879. }
  47880. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  47881. }
  47882. public function getUriRetriever()
  47883. {
  47884. if (is_null($this->uriRetriever)) {
  47885. $this->setUriRetriever(new FileGetContents());
  47886. }
  47887. return $this->uriRetriever;
  47888. }
  47889. public function resolvePointer($jsonSchema, $uri)
  47890. {
  47891. $resolver = new UriResolver();
  47892. $parsed = $resolver->parse($uri);
  47893. if (empty($parsed['fragment'])) {
  47894. return $jsonSchema;
  47895. }
  47896. $path = explode('/', $parsed['fragment']);
  47897. while ($path) {
  47898. $pathElement = array_shift($path);
  47899. if (!empty($pathElement)) {
  47900. $pathElement = str_replace('~1', '/', $pathElement);
  47901. $pathElement = str_replace('~0', '~', $pathElement);
  47902. if (!empty($jsonSchema->$pathElement)) {
  47903. $jsonSchema = $jsonSchema->$pathElement;
  47904. } else {
  47905. throw new ResourceNotFoundException(
  47906. 'Fragment "' . $parsed['fragment'] . '" not found'
  47907. . ' in ' . $uri
  47908. );
  47909. }
  47910. if (!is_object($jsonSchema)) {
  47911. throw new ResourceNotFoundException(
  47912. 'Fragment part "' . $pathElement . '" is no object '
  47913. . ' in ' . $uri
  47914. );
  47915. }
  47916. }
  47917. }
  47918. return $jsonSchema;
  47919. }
  47920. public function retrieve($uri, $baseUri = null, $translate = true)
  47921. {
  47922. $resolver = new UriResolver();
  47923. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  47924. $arParts = $resolver->parse($resolvedUri);
  47925. if (isset($arParts['fragment'])) {
  47926. unset($arParts['fragment']);
  47927. $fetchUri = $resolver->generate($arParts);
  47928. }
  47929. if ($translate) {
  47930. $fetchUri = $this->translate($fetchUri);
  47931. }
  47932. $jsonSchema = $this->loadSchema($fetchUri);
  47933. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  47934. if ($jsonSchema instanceof \stdClass) {
  47935. $jsonSchema->id = $resolvedUri;
  47936. }
  47937. return $jsonSchema;
  47938. }
  47939. protected function loadSchema($fetchUri)
  47940. {
  47941. if (isset($this->schemaCache[$fetchUri])) {
  47942. return $this->schemaCache[$fetchUri];
  47943. }
  47944. $uriRetriever = $this->getUriRetriever();
  47945. $contents = $this->uriRetriever->retrieve($fetchUri);
  47946. $this->confirmMediaType($uriRetriever, $fetchUri);
  47947. $jsonSchema = json_decode($contents);
  47948. if (JSON_ERROR_NONE < $error = json_last_error()) {
  47949. throw new JsonDecodingException($error);
  47950. }
  47951. $this->schemaCache[$fetchUri] = $jsonSchema;
  47952. return $jsonSchema;
  47953. }
  47954. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  47955. {
  47956. $this->uriRetriever = $uriRetriever;
  47957. return $this;
  47958. }
  47959. public function parse($uri)
  47960. {
  47961. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  47962. $components = array();
  47963. if (5 < count($match)) {
  47964. $components = array(
  47965. 'scheme' => $match[2],
  47966. 'authority' => $match[4],
  47967. 'path' => $match[5]
  47968. );
  47969. }
  47970. if (7 < count($match)) {
  47971. $components['query'] = $match[7];
  47972. }
  47973. if (9 < count($match)) {
  47974. $components['fragment'] = $match[9];
  47975. }
  47976. return $components;
  47977. }
  47978. public function generate(array $components)
  47979. {
  47980. $uri = $components['scheme'] . '://'
  47981. . $components['authority']
  47982. . $components['path'];
  47983. if (array_key_exists('query', $components)) {
  47984. $uri .= $components['query'];
  47985. }
  47986. if (array_key_exists('fragment', $components)) {
  47987. $uri .= $components['fragment'];
  47988. }
  47989. return $uri;
  47990. }
  47991. public function resolve($uri, $baseUri = null)
  47992. {
  47993. $components = $this->parse($uri);
  47994. $path = $components['path'];
  47995. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  47996. return $uri;
  47997. }
  47998. $baseComponents = $this->parse($baseUri);
  47999. $basePath = $baseComponents['path'];
  48000. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  48001. return $this->generate($baseComponents);
  48002. }
  48003. public function isValid($uri)
  48004. {
  48005. $components = $this->parse($uri);
  48006. return !empty($components);
  48007. }
  48008. public function setTranslation($from, $to)
  48009. {
  48010. $this->translationMap[$from] = $to;
  48011. }
  48012. public function translate($uri)
  48013. {
  48014. foreach ($this->translationMap as $from => $to) {
  48015. $uri = preg_replace($from, $to, $uri);
  48016. }
  48017. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  48018. return $uri;
  48019. }
  48020. }
  48021. <?php
  48022. namespace JsonSchema;
  48023. interface UriResolverInterface
  48024. {
  48025. public function resolve($uri, $baseUri = null);
  48026. }
  48027. <?php
  48028. namespace JsonSchema;
  48029. interface UriRetrieverInterface
  48030. {
  48031. public function retrieve($uri, $baseUri = null);
  48032. }
  48033. <?php
  48034. namespace JsonSchema;
  48035. use JsonSchema\Constraints\BaseConstraint;
  48036. use JsonSchema\Constraints\Constraint;
  48037. class Validator extends BaseConstraint
  48038. {
  48039. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  48040. const ERROR_NONE = 0x00000000;
  48041. const ERROR_ALL = 0xFFFFFFFF;
  48042. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  48043. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  48044. public function validate(&$value, $schema = null, $checkMode = null)
  48045. {
  48046. if (is_array($schema)) {
  48047. $schema = self::arrayToObjectRecursive($schema);
  48048. }
  48049. $initialCheckMode = $this->factory->getConfig();
  48050. if ($checkMode !== null) {
  48051. $this->factory->setConfig($checkMode);
  48052. }
  48053. if (is_object($schema) && property_exists($schema, 'id')) {
  48054. $schemaURI = $schema->id;
  48055. } else {
  48056. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  48057. }
  48058. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  48059. $validator = $this->factory->createInstanceFor('schema');
  48060. $validator->check(
  48061. $value,
  48062. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  48063. );
  48064. $this->factory->setConfig($initialCheckMode);
  48065. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  48066. return $validator->getErrorMask();
  48067. }
  48068. public function check($value, $schema)
  48069. {
  48070. return $this->validate($value, $schema);
  48071. }
  48072. public function coerce(&$value, $schema)
  48073. {
  48074. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  48075. }
  48076. }
  48077. Copyright (c) 2012 PHP Framework Interoperability Group
  48078. Permission is hereby granted, free of charge, to any person obtaining a copy
  48079. of this software and associated documentation files (the "Software"), to deal
  48080. in the Software without restriction, including without limitation the rights
  48081. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  48082. copies of the Software, and to permit persons to whom the Software is
  48083. furnished to do so, subject to the following conditions:
  48084. The above copyright notice and this permission notice shall be included in
  48085. all copies or substantial portions of the Software.
  48086. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  48087. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  48088. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  48089. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  48090. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  48091. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  48092. THE SOFTWARE.
  48093. <?php
  48094. namespace Psr\Log;
  48095. abstract class AbstractLogger implements LoggerInterface
  48096. {
  48097. public function emergency($message, array $context = array())
  48098. {
  48099. $this->log(LogLevel::EMERGENCY, $message, $context);
  48100. }
  48101. public function alert($message, array $context = array())
  48102. {
  48103. $this->log(LogLevel::ALERT, $message, $context);
  48104. }
  48105. public function critical($message, array $context = array())
  48106. {
  48107. $this->log(LogLevel::CRITICAL, $message, $context);
  48108. }
  48109. public function error($message, array $context = array())
  48110. {
  48111. $this->log(LogLevel::ERROR, $message, $context);
  48112. }
  48113. public function warning($message, array $context = array())
  48114. {
  48115. $this->log(LogLevel::WARNING, $message, $context);
  48116. }
  48117. public function notice($message, array $context = array())
  48118. {
  48119. $this->log(LogLevel::NOTICE, $message, $context);
  48120. }
  48121. public function info($message, array $context = array())
  48122. {
  48123. $this->log(LogLevel::INFO, $message, $context);
  48124. }
  48125. public function debug($message, array $context = array())
  48126. {
  48127. $this->log(LogLevel::DEBUG, $message, $context);
  48128. }
  48129. }
  48130. <?php
  48131. namespace Psr\Log;
  48132. class InvalidArgumentException extends \InvalidArgumentException
  48133. {
  48134. }
  48135. <?php
  48136. namespace Psr\Log;
  48137. class LogLevel
  48138. {
  48139. const EMERGENCY = 'emergency';
  48140. const ALERT = 'alert';
  48141. const CRITICAL = 'critical';
  48142. const ERROR = 'error';
  48143. const WARNING = 'warning';
  48144. const NOTICE = 'notice';
  48145. const INFO = 'info';
  48146. const DEBUG = 'debug';
  48147. }
  48148. <?php
  48149. namespace Psr\Log;
  48150. interface LoggerAwareInterface
  48151. {
  48152. public function setLogger(LoggerInterface $logger);
  48153. }
  48154. <?php
  48155. namespace Psr\Log;
  48156. trait LoggerAwareTrait
  48157. {
  48158. protected $logger;
  48159. public function setLogger(LoggerInterface $logger)
  48160. {
  48161. $this->logger = $logger;
  48162. }
  48163. }
  48164. <?php
  48165. namespace Psr\Log;
  48166. interface LoggerInterface
  48167. {
  48168. public function emergency($message, array $context = array());
  48169. public function alert($message, array $context = array());
  48170. public function critical($message, array $context = array());
  48171. public function error($message, array $context = array());
  48172. public function warning($message, array $context = array());
  48173. public function notice($message, array $context = array());
  48174. public function info($message, array $context = array());
  48175. public function debug($message, array $context = array());
  48176. public function log($level, $message, array $context = array());
  48177. }
  48178. <?php
  48179. namespace Psr\Log;
  48180. trait LoggerTrait
  48181. {
  48182. public function emergency($message, array $context = array())
  48183. {
  48184. $this->log(LogLevel::EMERGENCY, $message, $context);
  48185. }
  48186. public function alert($message, array $context = array())
  48187. {
  48188. $this->log(LogLevel::ALERT, $message, $context);
  48189. }
  48190. public function critical($message, array $context = array())
  48191. {
  48192. $this->log(LogLevel::CRITICAL, $message, $context);
  48193. }
  48194. public function error($message, array $context = array())
  48195. {
  48196. $this->log(LogLevel::ERROR, $message, $context);
  48197. }
  48198. public function warning($message, array $context = array())
  48199. {
  48200. $this->log(LogLevel::WARNING, $message, $context);
  48201. }
  48202. public function notice($message, array $context = array())
  48203. {
  48204. $this->log(LogLevel::NOTICE, $message, $context);
  48205. }
  48206. public function info($message, array $context = array())
  48207. {
  48208. $this->log(LogLevel::INFO, $message, $context);
  48209. }
  48210. public function debug($message, array $context = array())
  48211. {
  48212. $this->log(LogLevel::DEBUG, $message, $context);
  48213. }
  48214. abstract public function log($level, $message, array $context = array());
  48215. }
  48216. <?php
  48217. namespace Psr\Log;
  48218. class NullLogger extends AbstractLogger
  48219. {
  48220. public function log($level, $message, array $context = array())
  48221. {
  48222. }
  48223. }
  48224. <?php
  48225. namespace Psr\Log\Test;
  48226. class DummyTest
  48227. {
  48228. public function __toString()
  48229. {
  48230. return 'DummyTest';
  48231. }
  48232. }
  48233. <?php
  48234. namespace Psr\Log\Test;
  48235. use Psr\Log\LoggerInterface;
  48236. use Psr\Log\LogLevel;
  48237. use PHPUnit\Framework\TestCase;
  48238. abstract class LoggerInterfaceTest extends TestCase
  48239. {
  48240. abstract public function getLogger();
  48241. abstract public function getLogs();
  48242. public function testImplements()
  48243. {
  48244. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  48245. }
  48246. public function testLogsAtAllLevels($level, $message)
  48247. {
  48248. $logger = $this->getLogger();
  48249. $logger->{$level}($message, array('user' => 'Bob'));
  48250. $logger->log($level, $message, array('user' => 'Bob'));
  48251. $expected = array(
  48252. $level.' message of level '.$level.' with context: Bob',
  48253. $level.' message of level '.$level.' with context: Bob',
  48254. );
  48255. $this->assertEquals($expected, $this->getLogs());
  48256. }
  48257. public function provideLevelsAndMessages()
  48258. {
  48259. return array(
  48260. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  48261. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  48262. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  48263. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  48264. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  48265. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  48266. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  48267. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  48268. );
  48269. }
  48270. public function testThrowsOnInvalidLevel()
  48271. {
  48272. $logger = $this->getLogger();
  48273. $logger->log('invalid level', 'Foo');
  48274. }
  48275. public function testContextReplacement()
  48276. {
  48277. $logger = $this->getLogger();
  48278. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  48279. $expected = array('info {Message {nothing} Bob Bar a}');
  48280. $this->assertEquals($expected, $this->getLogs());
  48281. }
  48282. public function testObjectCastToString()
  48283. {
  48284. if (method_exists($this, 'createPartialMock')) {
  48285. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  48286. } else {
  48287. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  48288. }
  48289. $dummy->expects($this->once())
  48290. ->method('__toString')
  48291. ->will($this->returnValue('DUMMY'));
  48292. $this->getLogger()->warning($dummy);
  48293. $expected = array('warning DUMMY');
  48294. $this->assertEquals($expected, $this->getLogs());
  48295. }
  48296. public function testContextCanContainAnything()
  48297. {
  48298. $closed = fopen('php://memory', 'r');
  48299. fclose($closed);
  48300. $context = array(
  48301. 'bool' => true,
  48302. 'null' => null,
  48303. 'string' => 'Foo',
  48304. 'int' => 0,
  48305. 'float' => 0.5,
  48306. 'nested' => array('with object' => new DummyTest),
  48307. 'object' => new \DateTime,
  48308. 'resource' => fopen('php://memory', 'r'),
  48309. 'closed' => $closed,
  48310. );
  48311. $this->getLogger()->warning('Crazy context data', $context);
  48312. $expected = array('warning Crazy context data');
  48313. $this->assertEquals($expected, $this->getLogs());
  48314. }
  48315. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  48316. {
  48317. $logger = $this->getLogger();
  48318. $logger->warning('Random message', array('exception' => 'oops'));
  48319. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  48320. $expected = array(
  48321. 'warning Random message',
  48322. 'critical Uncaught Exception!'
  48323. );
  48324. $this->assertEquals($expected, $this->getLogs());
  48325. }
  48326. }
  48327. <?php
  48328. namespace Psr\Log\Test;
  48329. use Psr\Log\AbstractLogger;
  48330. class TestLogger extends AbstractLogger
  48331. {
  48332. public $records = [];
  48333. public $recordsByLevel = [];
  48334. public function log($level, $message, array $context = [])
  48335. {
  48336. $record = [
  48337. 'level' => $level,
  48338. 'message' => $message,
  48339. 'context' => $context,
  48340. ];
  48341. $this->recordsByLevel[$record['level']][] = $record;
  48342. $this->records[] = $record;
  48343. }
  48344. public function hasRecords($level)
  48345. {
  48346. return isset($this->recordsByLevel[$level]);
  48347. }
  48348. public function hasRecord($record, $level)
  48349. {
  48350. if (is_string($record)) {
  48351. $record = ['message' => $record];
  48352. }
  48353. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  48354. if ($rec['message'] !== $record['message']) {
  48355. return false;
  48356. }
  48357. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  48358. return false;
  48359. }
  48360. return true;
  48361. }, $level);
  48362. }
  48363. public function hasRecordThatContains($message, $level)
  48364. {
  48365. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  48366. return strpos($rec['message'], $message) !== false;
  48367. }, $level);
  48368. }
  48369. public function hasRecordThatMatches($regex, $level)
  48370. {
  48371. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  48372. return preg_match($regex, $rec['message']) > 0;
  48373. }, $level);
  48374. }
  48375. public function hasRecordThatPasses(callable $predicate, $level)
  48376. {
  48377. if (!isset($this->recordsByLevel[$level])) {
  48378. return false;
  48379. }
  48380. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  48381. if (call_user_func($predicate, $rec, $i)) {
  48382. return true;
  48383. }
  48384. }
  48385. return false;
  48386. }
  48387. public function __call($method, $args)
  48388. {
  48389. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  48390. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  48391. $level = strtolower($matches[2]);
  48392. if (method_exists($this, $genericMethod)) {
  48393. $args[] = $level;
  48394. return call_user_func_array([$this, $genericMethod], $args);
  48395. }
  48396. }
  48397. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  48398. }
  48399. public function reset()
  48400. {
  48401. $this->records = [];
  48402. $this->recordsByLevel = [];
  48403. }
  48404. }
  48405. Copyright (c) 2012-2016 Jan Sorgalla
  48406. Permission is hereby granted, free of charge, to any person
  48407. obtaining a copy of this software and associated documentation
  48408. files (the "Software"), to deal in the Software without
  48409. restriction, including without limitation the rights to use,
  48410. copy, modify, merge, publish, distribute, sublicense, and/or sell
  48411. copies of the Software, and to permit persons to whom the
  48412. Software is furnished to do so, subject to the following
  48413. conditions:
  48414. The above copyright notice and this permission notice shall be
  48415. included in all copies or substantial portions of the Software.
  48416. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  48417. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  48418. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  48419. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  48420. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  48421. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  48422. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  48423. OTHER DEALINGS IN THE SOFTWARE.
  48424. <?php
  48425. namespace React\Promise;
  48426. interface CancellablePromiseInterface extends PromiseInterface
  48427. {
  48428. public function cancel();
  48429. }
  48430. <?php
  48431. namespace React\Promise;
  48432. class Deferred implements PromiseInterface, ResolverInterface, PromisorInterface, CancellablePromiseInterface
  48433. {
  48434. private $completed;
  48435. private $promise;
  48436. private $resolver;
  48437. private $handlers = array();
  48438. private $progressHandlers = array();
  48439. private $canceller;
  48440. private $requiredCancelRequests = 0;
  48441. private $cancelRequests = 0;
  48442. public function __construct($canceller = null)
  48443. {
  48444. if ($canceller !== null && !is_callable($canceller)) {
  48445. throw new \InvalidArgumentException(
  48446. sprintf(
  48447. 'The canceller argument must be null or of type callable, %s given.',
  48448. gettype($canceller)
  48449. )
  48450. );
  48451. }
  48452. $this->canceller = $canceller;
  48453. }
  48454. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  48455. {
  48456. if (null !== $this->completed) {
  48457. return $this->completed->then($fulfilledHandler, $errorHandler, $progressHandler);
  48458. }
  48459. $canceller = null;
  48460. if ($this->canceller !== null) {
  48461. $this->requiredCancelRequests++;
  48462. $that = $this;
  48463. $current =& $this->cancelRequests;
  48464. $required =& $this->requiredCancelRequests;
  48465. $canceller = function () use ($that, &$current, &$required) {
  48466. if (++$current < $required) {
  48467. return;
  48468. }
  48469. $that->cancel();
  48470. };
  48471. }
  48472. $deferred = new static($canceller);
  48473. if (is_callable($progressHandler)) {
  48474. $progHandler = function ($update) use ($deferred, $progressHandler) {
  48475. try {
  48476. $deferred->progress(call_user_func($progressHandler, $update));
  48477. } catch (\Exception $e) {
  48478. $deferred->progress($e);
  48479. }
  48480. };
  48481. } else {
  48482. if (null !== $progressHandler) {
  48483. trigger_error('Invalid $progressHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  48484. }
  48485. $progHandler = array($deferred, 'progress');
  48486. }
  48487. $this->handlers[] = function ($promise) use ($fulfilledHandler, $errorHandler, $deferred, $progHandler) {
  48488. $promise
  48489. ->then($fulfilledHandler, $errorHandler)
  48490. ->then(
  48491. array($deferred, 'resolve'),
  48492. array($deferred, 'reject'),
  48493. $progHandler
  48494. );
  48495. };
  48496. $this->progressHandlers[] = $progHandler;
  48497. return $deferred->promise();
  48498. }
  48499. public function resolve($result = null)
  48500. {
  48501. if (null !== $this->completed) {
  48502. return resolve($result);
  48503. }
  48504. $this->completed = resolve($result);
  48505. $this->processQueue($this->handlers, $this->completed);
  48506. $this->progressHandlers = $this->handlers = array();
  48507. return $this->completed;
  48508. }
  48509. public function reject($reason = null)
  48510. {
  48511. return $this->resolve(reject($reason));
  48512. }
  48513. public function progress($update = null)
  48514. {
  48515. if (null !== $this->completed) {
  48516. return;
  48517. }
  48518. $this->processQueue($this->progressHandlers, $update);
  48519. }
  48520. public function promise()
  48521. {
  48522. if (null === $this->promise) {
  48523. $this->promise = new DeferredPromise($this);
  48524. }
  48525. return $this->promise;
  48526. }
  48527. public function resolver()
  48528. {
  48529. if (null === $this->resolver) {
  48530. $this->resolver = new DeferredResolver($this);
  48531. }
  48532. return $this->resolver;
  48533. }
  48534. public function cancel()
  48535. {
  48536. if (null === $this->canceller || null !== $this->completed) {
  48537. return;
  48538. }
  48539. $canceller = $this->canceller;
  48540. $this->canceller = null;
  48541. try {
  48542. $that = $this;
  48543. call_user_func(
  48544. $canceller,
  48545. function ($value = null) use ($that) {
  48546. $that->resolve($value);
  48547. },
  48548. function ($reason = null) use ($that) {
  48549. $that->reject($reason);
  48550. },
  48551. function ($update = null) use ($that) {
  48552. $that->progress($update);
  48553. }
  48554. );
  48555. } catch (\Exception $e) {
  48556. $this->reject($e);
  48557. }
  48558. }
  48559. protected function processQueue($queue, $value)
  48560. {
  48561. foreach ($queue as $handler) {
  48562. call_user_func($handler, $value);
  48563. }
  48564. }
  48565. }
  48566. <?php
  48567. namespace React\Promise;
  48568. class DeferredPromise implements PromiseInterface, CancellablePromiseInterface
  48569. {
  48570. private $deferred;
  48571. public function __construct(Deferred $deferred)
  48572. {
  48573. $this->deferred = $deferred;
  48574. }
  48575. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  48576. {
  48577. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  48578. }
  48579. public function cancel()
  48580. {
  48581. $this->deferred->cancel();
  48582. }
  48583. }
  48584. <?php
  48585. namespace React\Promise;
  48586. class DeferredResolver implements ResolverInterface
  48587. {
  48588. private $deferred;
  48589. public function __construct(Deferred $deferred)
  48590. {
  48591. $this->deferred = $deferred;
  48592. }
  48593. public function resolve($result = null)
  48594. {
  48595. return $this->deferred->resolve($result);
  48596. }
  48597. public function reject($reason = null)
  48598. {
  48599. return $this->deferred->reject($reason);
  48600. }
  48601. public function progress($update = null)
  48602. {
  48603. return $this->deferred->progress($update);
  48604. }
  48605. }
  48606. <?php
  48607. namespace React\Promise;
  48608. class FulfilledPromise implements PromiseInterface, CancellablePromiseInterface
  48609. {
  48610. private $result;
  48611. public function __construct($result = null)
  48612. {
  48613. $this->result = $result;
  48614. }
  48615. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  48616. {
  48617. try {
  48618. $result = $this->result;
  48619. if (is_callable($fulfilledHandler)) {
  48620. $result = call_user_func($fulfilledHandler, $result);
  48621. } elseif (null !== $fulfilledHandler) {
  48622. trigger_error('Invalid $fulfilledHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  48623. }
  48624. return resolve($result);
  48625. } catch (\Exception $exception) {
  48626. return new RejectedPromise($exception);
  48627. }
  48628. }
  48629. public function cancel()
  48630. {
  48631. }
  48632. }
  48633. <?php
  48634. namespace React\Promise;
  48635. class LazyPromise implements PromiseInterface, CancellablePromiseInterface
  48636. {
  48637. private $factory;
  48638. private $promise;
  48639. public function __construct($factory)
  48640. {
  48641. $this->factory = $factory;
  48642. }
  48643. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  48644. {
  48645. return $this->promise()->then($fulfilledHandler, $errorHandler, $progressHandler);
  48646. }
  48647. public function cancel()
  48648. {
  48649. $promise = $this->promise();
  48650. if ($promise instanceof CancellablePromiseInterface) {
  48651. $promise->cancel();
  48652. }
  48653. }
  48654. private function promise()
  48655. {
  48656. if (null === $this->promise) {
  48657. try {
  48658. $this->promise = resolve(call_user_func($this->factory));
  48659. } catch (\Exception $exception) {
  48660. $this->promise = new RejectedPromise($exception);
  48661. }
  48662. }
  48663. return $this->promise;
  48664. }
  48665. }
  48666. <?php
  48667. namespace React\Promise;
  48668. class Promise implements PromiseInterface, CancellablePromiseInterface
  48669. {
  48670. private $deferred;
  48671. public function __construct($resolver, $canceller = null)
  48672. {
  48673. if (!is_callable($resolver)) {
  48674. throw new \InvalidArgumentException(
  48675. sprintf(
  48676. 'The resolver argument must be of type callable, %s given.',
  48677. gettype($resolver)
  48678. )
  48679. );
  48680. }
  48681. $this->deferred = new Deferred($canceller);
  48682. $this->call($resolver);
  48683. }
  48684. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  48685. {
  48686. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  48687. }
  48688. public function cancel()
  48689. {
  48690. $this->deferred->cancel();
  48691. }
  48692. private function call($callback)
  48693. {
  48694. $deferred = $this->deferred;
  48695. try {
  48696. call_user_func(
  48697. $callback,
  48698. function ($result = null) use ($deferred) {
  48699. $deferred->resolve($result);
  48700. },
  48701. function ($reason = null) use ($deferred) {
  48702. $deferred->reject($reason);
  48703. },
  48704. function ($update = null) use ($deferred) {
  48705. $deferred->progress($update);
  48706. }
  48707. );
  48708. } catch (\Exception $e) {
  48709. $this->deferred->reject($e);
  48710. }
  48711. }
  48712. }
  48713. <?php
  48714. namespace React\Promise;
  48715. interface PromiseInterface
  48716. {
  48717. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null);
  48718. }
  48719. <?php
  48720. namespace React\Promise;
  48721. interface PromisorInterface
  48722. {
  48723. public function promise();
  48724. }
  48725. <?php
  48726. namespace React\Promise;
  48727. class RejectedPromise implements PromiseInterface, CancellablePromiseInterface
  48728. {
  48729. private $reason;
  48730. public function __construct($reason = null)
  48731. {
  48732. $this->reason = $reason;
  48733. }
  48734. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  48735. {
  48736. try {
  48737. if (!is_callable($errorHandler)) {
  48738. if (null !== $errorHandler) {
  48739. trigger_error('Invalid $errorHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  48740. }
  48741. return new RejectedPromise($this->reason);
  48742. }
  48743. return resolve(call_user_func($errorHandler, $this->reason));
  48744. } catch (\Exception $exception) {
  48745. return new RejectedPromise($exception);
  48746. }
  48747. }
  48748. public function cancel()
  48749. {
  48750. }
  48751. }
  48752. <?php
  48753. namespace React\Promise;
  48754. interface ResolverInterface
  48755. {
  48756. public function resolve($result = null);
  48757. public function reject($reason = null);
  48758. public function progress($update = null);
  48759. }
  48760. <?php
  48761. namespace React\Promise;
  48762. class Util
  48763. {
  48764. public static function promiseFor($promiseOrValue)
  48765. {
  48766. return resolve($promiseOrValue);
  48767. }
  48768. public static function rejectedPromiseFor($promiseOrValue)
  48769. {
  48770. return reject($promiseOrValue);
  48771. }
  48772. }
  48773. <?php
  48774. namespace React\Promise;
  48775. class When
  48776. {
  48777. public static function resolve($promiseOrValue = null)
  48778. {
  48779. return resolve($promiseOrValue);
  48780. }
  48781. public static function reject($promiseOrValue = null)
  48782. {
  48783. return reject($promiseOrValue);
  48784. }
  48785. public static function lazy($factory)
  48786. {
  48787. return new LazyPromise($factory);
  48788. }
  48789. public static function all($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  48790. {
  48791. return all($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  48792. }
  48793. public static function any($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  48794. {
  48795. return any($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  48796. }
  48797. public static function some($promisesOrValues, $howMany, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  48798. {
  48799. return some($promisesOrValues, $howMany)->then($fulfilledHandler, $errorHandler, $progressHandler);
  48800. }
  48801. public static function map($promisesOrValues, $mapFunc)
  48802. {
  48803. return map($promisesOrValues, $mapFunc);
  48804. }
  48805. public static function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  48806. {
  48807. return reduce($promisesOrValues, $reduceFunc, $initialValue);
  48808. }
  48809. }
  48810. <?php
  48811. namespace React\Promise;
  48812. function resolve($promiseOrValue = null)
  48813. {
  48814. if ($promiseOrValue instanceof PromiseInterface) {
  48815. return $promiseOrValue;
  48816. }
  48817. return new FulfilledPromise($promiseOrValue);
  48818. }
  48819. function reject($promiseOrValue = null)
  48820. {
  48821. if ($promiseOrValue instanceof PromiseInterface) {
  48822. return $promiseOrValue->then(function ($value) {
  48823. return new RejectedPromise($value);
  48824. });
  48825. }
  48826. return new RejectedPromise($promiseOrValue);
  48827. }
  48828. function all($promisesOrValues)
  48829. {
  48830. return map($promisesOrValues, function ($val) {
  48831. return $val;
  48832. });
  48833. }
  48834. function any($promisesOrValues)
  48835. {
  48836. return some($promisesOrValues, 1)->then(function($val) {
  48837. return array_shift($val);
  48838. });
  48839. }
  48840. function some($promisesOrValues, $howMany)
  48841. {
  48842. return resolve($promisesOrValues)->then(function ($array) use ($howMany) {
  48843. if (!is_array($array)) {
  48844. $array = array();
  48845. }
  48846. $len = count($array);
  48847. $toResolve = max(0, min($howMany, $len));
  48848. $values = array();
  48849. $deferred = new Deferred();
  48850. if (!$toResolve) {
  48851. $deferred->resolve($values);
  48852. } else {
  48853. $toReject = ($len - $toResolve) + 1;
  48854. $reasons = array();
  48855. $progress = array($deferred, 'progress');
  48856. $fulfillOne = function ($val, $i) use (&$values, &$toResolve, $deferred) {
  48857. $values[$i] = $val;
  48858. if (0 === --$toResolve) {
  48859. $deferred->resolve($values);
  48860. return true;
  48861. }
  48862. };
  48863. $rejectOne = function ($reason, $i) use (&$reasons, &$toReject, $deferred) {
  48864. $reasons[$i] = $reason;
  48865. if (0 === --$toReject) {
  48866. $deferred->reject($reasons);
  48867. return true;
  48868. }
  48869. };
  48870. foreach ($array as $i => $promiseOrValue) {
  48871. $fulfiller = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  48872. $reset = $fulfillOne($val, $i);
  48873. if (true === $reset) {
  48874. $fulfillOne = $rejectOne = function () {};
  48875. }
  48876. };
  48877. $rejecter = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  48878. $reset = $rejectOne($val, $i);
  48879. if (true === $reset) {
  48880. $fulfillOne = $rejectOne = function () {};
  48881. }
  48882. };
  48883. resolve($promiseOrValue)->then($fulfiller, $rejecter, $progress);
  48884. }
  48885. }
  48886. return $deferred->promise();
  48887. });
  48888. }
  48889. function map($promisesOrValues, $mapFunc)
  48890. {
  48891. return resolve($promisesOrValues)->then(function ($array) use ($mapFunc) {
  48892. if (!is_array($array)) {
  48893. $array = array();
  48894. }
  48895. $toResolve = count($array);
  48896. $results = array();
  48897. $deferred = new Deferred();
  48898. if (!$toResolve) {
  48899. $deferred->resolve($results);
  48900. } else {
  48901. $resolve = function ($item, $i) use ($mapFunc, &$results, &$toResolve, $deferred) {
  48902. resolve($item)
  48903. ->then($mapFunc)
  48904. ->then(
  48905. function ($mapped) use (&$results, $i, &$toResolve, $deferred) {
  48906. $results[$i] = $mapped;
  48907. if (0 === --$toResolve) {
  48908. $deferred->resolve($results);
  48909. }
  48910. },
  48911. array($deferred, 'reject')
  48912. );
  48913. };
  48914. foreach ($array as $i => $item) {
  48915. $resolve($item, $i);
  48916. }
  48917. }
  48918. return $deferred->promise();
  48919. });
  48920. }
  48921. function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  48922. {
  48923. return resolve($promisesOrValues)->then(function ($array) use ($reduceFunc, $initialValue) {
  48924. if (!is_array($array)) {
  48925. $array = array();
  48926. }
  48927. $total = count($array);
  48928. $i = 0;
  48929. $wrappedReduceFunc = function ($current, $val) use ($reduceFunc, $total, &$i) {
  48930. return resolve($current)->then(function ($c) use ($reduceFunc, $total, &$i, $val) {
  48931. return resolve($val)->then(function ($value) use ($reduceFunc, $total, &$i, $c) {
  48932. return call_user_func($reduceFunc, $c, $value, $i++, $total);
  48933. });
  48934. });
  48935. };
  48936. return array_reduce($array, $wrappedReduceFunc, $initialValue);
  48937. });
  48938. }
  48939. <?php
  48940. if (!function_exists('React\Promise\resolve')) {
  48941. require __DIR__.'/functions.php';
  48942. }
  48943. Copyright (c) 2011 Jordi Boggiano
  48944. Permission is hereby granted, free of charge, to any person obtaining a copy
  48945. of this software and associated documentation files (the "Software"), to deal
  48946. in the Software without restriction, including without limitation the rights
  48947. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  48948. copies of the Software, and to permit persons to whom the Software is furnished
  48949. to do so, subject to the following conditions:
  48950. The above copyright notice and this permission notice shall be included in all
  48951. copies or substantial portions of the Software.
  48952. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  48953. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  48954. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  48955. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  48956. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  48957. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  48958. THE SOFTWARE.
  48959. <?php
  48960. namespace Seld\JsonLint;
  48961. class DuplicateKeyException extends ParsingException
  48962. {
  48963. public function __construct($message, $key, array $details = array())
  48964. {
  48965. $details['key'] = $key;
  48966. parent::__construct($message, $details);
  48967. }
  48968. public function getKey()
  48969. {
  48970. return $this->details['key'];
  48971. }
  48972. public function getDetails()
  48973. {
  48974. return $this->details;
  48975. }
  48976. }
  48977. <?php
  48978. namespace Seld\JsonLint;
  48979. use stdClass;
  48980. class JsonParser
  48981. {
  48982. const DETECT_KEY_CONFLICTS = 1;
  48983. const ALLOW_DUPLICATE_KEYS = 2;
  48984. const PARSE_TO_ASSOC = 4;
  48985. private $lexer;
  48986. private $flags;
  48987. private $stack;
  48988. private $vstack;
  48989. private $lstack;
  48990. private $symbols = array(
  48991. 'error' => 2,
  48992. 'JSONString' => 3,
  48993. 'STRING' => 4,
  48994. 'JSONNumber' => 5,
  48995. 'NUMBER' => 6,
  48996. 'JSONNullLiteral' => 7,
  48997. 'NULL' => 8,
  48998. 'JSONBooleanLiteral' => 9,
  48999. 'TRUE' => 10,
  49000. 'FALSE' => 11,
  49001. 'JSONText' => 12,
  49002. 'JSONValue' => 13,
  49003. 'EOF' => 14,
  49004. 'JSONObject' => 15,
  49005. 'JSONArray' => 16,
  49006. '{' => 17,
  49007. '}' => 18,
  49008. 'JSONMemberList' => 19,
  49009. 'JSONMember' => 20,
  49010. ':' => 21,
  49011. ',' => 22,
  49012. '[' => 23,
  49013. ']' => 24,
  49014. 'JSONElementList' => 25,
  49015. '$accept' => 0,
  49016. '$end' => 1,
  49017. );
  49018. private $terminals_ = array(
  49019. 2 => "error",
  49020. 4 => "STRING",
  49021. 6 => "NUMBER",
  49022. 8 => "NULL",
  49023. 10 => "TRUE",
  49024. 11 => "FALSE",
  49025. 14 => "EOF",
  49026. 17 => "{",
  49027. 18 => "}",
  49028. 21 => ":",
  49029. 22 => ",",
  49030. 23 => "[",
  49031. 24 => "]",
  49032. );
  49033. private $productions_ = array(
  49034. 0,
  49035. array(3, 1),
  49036. array(5, 1),
  49037. array(7, 1),
  49038. array(9, 1),
  49039. array(9, 1),
  49040. array(12, 2),
  49041. array(13, 1),
  49042. array(13, 1),
  49043. array(13, 1),
  49044. array(13, 1),
  49045. array(13, 1),
  49046. array(13, 1),
  49047. array(15, 2),
  49048. array(15, 3),
  49049. array(20, 3),
  49050. array(19, 1),
  49051. array(19, 3),
  49052. array(16, 2),
  49053. array(16, 3),
  49054. array(25, 1),
  49055. array(25, 3)
  49056. );
  49057. 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)),
  49058. );
  49059. private $defaultActions = array(
  49060. 16 => array(2, 6)
  49061. );
  49062. public function lint($input, $flags = 0)
  49063. {
  49064. try {
  49065. $this->parse($input, $flags);
  49066. } catch (ParsingException $e) {
  49067. return $e;
  49068. }
  49069. return null;
  49070. }
  49071. public function parse($input, $flags = 0)
  49072. {
  49073. $this->failOnBOM($input);
  49074. $this->flags = $flags;
  49075. $this->stack = array(0);
  49076. $this->vstack = array(null);
  49077. $this->lstack = array();
  49078. $yytext = '';
  49079. $yylineno = 0;
  49080. $yyleng = 0;
  49081. $recovering = 0;
  49082. $TERROR = 2;
  49083. $EOF = 1;
  49084. $this->lexer = new Lexer();
  49085. $this->lexer->setInput($input);
  49086. $yyloc = $this->lexer->yylloc;
  49087. $this->lstack[] = $yyloc;
  49088. $symbol = null;
  49089. $preErrorSymbol = null;
  49090. $state = null;
  49091. $action = null;
  49092. $a = null;
  49093. $r = null;
  49094. $yyval = new stdClass;
  49095. $p = null;
  49096. $len = null;
  49097. $newState = null;
  49098. $expected = null;
  49099. $errStr = null;
  49100. while (true) {
  49101. $state = $this->stack[\count($this->stack)-1];
  49102. if (isset($this->defaultActions[$state])) {
  49103. $action = $this->defaultActions[$state];
  49104. } else {
  49105. if ($symbol == null) {
  49106. $symbol = $this->lex();
  49107. }
  49108. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  49109. }
  49110. if (!$action || !$action[0]) {
  49111. if (!$recovering) {
  49112. $expected = array();
  49113. foreach ($this->table[$state] as $p => $ignore) {
  49114. if (isset($this->terminals_[$p]) && $p > 2) {
  49115. $expected[] = "'" . $this->terminals_[$p] . "'";
  49116. }
  49117. }
  49118. $message = null;
  49119. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  49120. $message = "Invalid string";
  49121. if ("'" === substr($this->lexer->match, 0, 1)) {
  49122. $message .= ", it appears you used single quotes instead of double quotes";
  49123. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  49124. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  49125. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  49126. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  49127. }
  49128. }
  49129. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  49130. $errStr .= $this->lexer->showPosition() . "\n";
  49131. if ($message) {
  49132. $errStr .= $message;
  49133. } else {
  49134. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  49135. $errStr .= implode(', ', $expected);
  49136. }
  49137. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  49138. $errStr .= " - It appears you have an extra trailing comma";
  49139. }
  49140. $this->parseError($errStr, array(
  49141. 'text' => $this->lexer->match,
  49142. 'token' => !empty($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  49143. 'line' => $this->lexer->yylineno,
  49144. 'loc' => $yyloc,
  49145. 'expected' => $expected,
  49146. ));
  49147. }
  49148. if ($recovering == 3) {
  49149. if ($symbol == $EOF) {
  49150. throw new ParsingException($errStr ?: 'Parsing halted.');
  49151. }
  49152. $yyleng = $this->lexer->yyleng;
  49153. $yytext = $this->lexer->yytext;
  49154. $yylineno = $this->lexer->yylineno;
  49155. $yyloc = $this->lexer->yylloc;
  49156. $symbol = $this->lex();
  49157. }
  49158. while (true) {
  49159. if (\array_key_exists($TERROR, $this->table[$state])) {
  49160. break;
  49161. }
  49162. if ($state == 0) {
  49163. throw new ParsingException($errStr ?: 'Parsing halted.');
  49164. }
  49165. $this->popStack(1);
  49166. $state = $this->stack[\count($this->stack)-1];
  49167. }
  49168. $preErrorSymbol = $symbol;
  49169. $symbol = $TERROR;
  49170. $state = $this->stack[\count($this->stack)-1];
  49171. $action = isset($this->table[$state][$TERROR]) ? $this->table[$state][$TERROR] : false;
  49172. $recovering = 3;
  49173. }
  49174. if (\is_array($action[0]) && \count($action) > 1) {
  49175. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  49176. }
  49177. switch ($action[0]) {
  49178. case 1:
  49179. $this->stack[] = $symbol;
  49180. $this->vstack[] = $this->lexer->yytext;
  49181. $this->lstack[] = $this->lexer->yylloc;
  49182. $this->stack[] = $action[1];
  49183. $symbol = null;
  49184. if (!$preErrorSymbol) {
  49185. $yyleng = $this->lexer->yyleng;
  49186. $yytext = $this->lexer->yytext;
  49187. $yylineno = $this->lexer->yylineno;
  49188. $yyloc = $this->lexer->yylloc;
  49189. if ($recovering > 0) {
  49190. $recovering--;
  49191. }
  49192. } else {
  49193. $symbol = $preErrorSymbol;
  49194. $preErrorSymbol = null;
  49195. }
  49196. break;
  49197. case 2:
  49198. $len = $this->productions_[$action[1]][1];
  49199. $yyval->token = $this->vstack[\count($this->vstack) - $len];
  49200. $yyval->store = array(
  49201. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  49202. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  49203. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  49204. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  49205. );
  49206. $r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack);
  49207. if (!$r instanceof Undefined) {
  49208. return $r;
  49209. }
  49210. if ($len) {
  49211. $this->popStack($len);
  49212. }
  49213. $this->stack[] = $this->productions_[$action[1]][0];
  49214. $this->vstack[] = $yyval->token;
  49215. $this->lstack[] = $yyval->store;
  49216. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  49217. $this->stack[] = $newState;
  49218. break;
  49219. case 3:
  49220. return true;
  49221. }
  49222. }
  49223. }
  49224. protected function parseError($str, $hash)
  49225. {
  49226. throw new ParsingException($str, $hash);
  49227. }
  49228. private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yystate, &$tokens)
  49229. {
  49230. $len = \count($tokens) - 1;
  49231. switch ($yystate) {
  49232. case 1:
  49233. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  49234. $yyval->token = $yytext;
  49235. break;
  49236. case 2:
  49237. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  49238. $yyval->token = \floatval($yytext);
  49239. } else {
  49240. $yyval->token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  49241. }
  49242. break;
  49243. case 3:
  49244. $yyval->token = null;
  49245. break;
  49246. case 4:
  49247. $yyval->token = true;
  49248. break;
  49249. case 5:
  49250. $yyval->token = false;
  49251. break;
  49252. case 6:
  49253. return $yyval->token = $tokens[$len-1];
  49254. case 13:
  49255. if ($this->flags & self::PARSE_TO_ASSOC) {
  49256. $yyval->token = array();
  49257. } else {
  49258. $yyval->token = new stdClass;
  49259. }
  49260. break;
  49261. case 14:
  49262. $yyval->token = $tokens[$len-1];
  49263. break;
  49264. case 15:
  49265. $yyval->token = array($tokens[$len-2], $tokens[$len]);
  49266. break;
  49267. case 16:
  49268. if (PHP_VERSION_ID < 70100) {
  49269. $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  49270. } else {
  49271. $property = $tokens[$len][0];
  49272. }
  49273. if ($this->flags & self::PARSE_TO_ASSOC) {
  49274. $yyval->token = array();
  49275. $yyval->token[$property] = $tokens[$len][1];
  49276. } else {
  49277. $yyval->token = new stdClass;
  49278. $yyval->token->$property = $tokens[$len][1];
  49279. }
  49280. break;
  49281. case 17:
  49282. if ($this->flags & self::PARSE_TO_ASSOC) {
  49283. $yyval->token =& $tokens[$len-2];
  49284. $key = $tokens[$len][0];
  49285. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2][$key])) {
  49286. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  49287. $errStr .= $this->lexer->showPosition() . "\n";
  49288. $errStr .= "Duplicate key: ".$tokens[$len][0];
  49289. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  49290. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2][$key])) {
  49291. $duplicateCount = 1;
  49292. do {
  49293. $duplicateKey = $key . '.' . $duplicateCount++;
  49294. } while (isset($tokens[$len-2][$duplicateKey]));
  49295. $key = $duplicateKey;
  49296. }
  49297. $tokens[$len-2][$key] = $tokens[$len][1];
  49298. } else {
  49299. $yyval->token = $tokens[$len-2];
  49300. if (PHP_VERSION_ID < 70100) {
  49301. $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  49302. } else {
  49303. $key = $tokens[$len][0];
  49304. }
  49305. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2]->{$key})) {
  49306. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  49307. $errStr .= $this->lexer->showPosition() . "\n";
  49308. $errStr .= "Duplicate key: ".$tokens[$len][0];
  49309. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  49310. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2]->{$key})) {
  49311. $duplicateCount = 1;
  49312. do {
  49313. $duplicateKey = $key . '.' . $duplicateCount++;
  49314. } while (isset($tokens[$len-2]->$duplicateKey));
  49315. $key = $duplicateKey;
  49316. }
  49317. $tokens[$len-2]->$key = $tokens[$len][1];
  49318. }
  49319. break;
  49320. case 18:
  49321. $yyval->token = array();
  49322. break;
  49323. case 19:
  49324. $yyval->token = $tokens[$len-1];
  49325. break;
  49326. case 20:
  49327. $yyval->token = array($tokens[$len]);
  49328. break;
  49329. case 21:
  49330. $tokens[$len-2][] = $tokens[$len];
  49331. $yyval->token = $tokens[$len-2];
  49332. break;
  49333. }
  49334. return new Undefined();
  49335. }
  49336. private function stringInterpolation($match)
  49337. {
  49338. switch ($match[0]) {
  49339. case '\\\\':
  49340. return '\\';
  49341. case '\"':
  49342. return '"';
  49343. case '\b':
  49344. return \chr(8);
  49345. case '\f':
  49346. return \chr(12);
  49347. case '\n':
  49348. return "\n";
  49349. case '\r':
  49350. return "\r";
  49351. case '\t':
  49352. return "\t";
  49353. case '\/':
  49354. return "/";
  49355. default:
  49356. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  49357. }
  49358. }
  49359. private function popStack($n)
  49360. {
  49361. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  49362. $this->vstack = \array_slice($this->vstack, 0, - $n);
  49363. $this->lstack = \array_slice($this->lstack, 0, - $n);
  49364. }
  49365. private function lex()
  49366. {
  49367. $token = $this->lexer->lex() ?: 1;
  49368. if (!is_numeric($token)) {
  49369. $token = isset($this->symbols[$token]) ? $this->symbols[$token] : $token;
  49370. }
  49371. return $token;
  49372. }
  49373. private function failOnBOM($input)
  49374. {
  49375. $bom = "\xEF\xBB\xBF";
  49376. if (substr($input, 0, 3) === $bom) {
  49377. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
  49378. }
  49379. }
  49380. }
  49381. <?php
  49382. namespace Seld\JsonLint;
  49383. class Lexer
  49384. {
  49385. private $EOF = 1;
  49386. private $rules = array(
  49387. 0 => '/\G\s+/',
  49388. 1 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  49389. 2 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  49390. 3 => '/\G\{/',
  49391. 4 => '/\G\}/',
  49392. 5 => '/\G\[/',
  49393. 6 => '/\G\]/',
  49394. 7 => '/\G,/',
  49395. 8 => '/\G:/',
  49396. 9 => '/\Gtrue\b/',
  49397. 10 => '/\Gfalse\b/',
  49398. 11 => '/\Gnull\b/',
  49399. 12 => '/\G$/',
  49400. 13 => '/\G./',
  49401. );
  49402. private $conditions = array(
  49403. "INITIAL" => array(
  49404. "rules" => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13),
  49405. "inclusive" => true,
  49406. ),
  49407. );
  49408. private $conditionStack;
  49409. private $input;
  49410. private $more;
  49411. private $done;
  49412. private $offset;
  49413. public $match;
  49414. public $yylineno;
  49415. public $yyleng;
  49416. public $yytext;
  49417. public $yylloc;
  49418. public function lex()
  49419. {
  49420. $r = $this->next();
  49421. if (!$r instanceof Undefined) {
  49422. return $r;
  49423. }
  49424. return $this->lex();
  49425. }
  49426. public function setInput($input)
  49427. {
  49428. $this->input = $input;
  49429. $this->more = false;
  49430. $this->done = false;
  49431. $this->offset = 0;
  49432. $this->yylineno = $this->yyleng = 0;
  49433. $this->yytext = $this->match = '';
  49434. $this->conditionStack = array('INITIAL');
  49435. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  49436. return $this;
  49437. }
  49438. public function showPosition()
  49439. {
  49440. $pre = str_replace("\n", '', $this->getPastInput());
  49441. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  49442. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  49443. }
  49444. public function getPastInput()
  49445. {
  49446. $pastLength = $this->offset - \strlen($this->match);
  49447. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  49448. }
  49449. public function getUpcomingInput()
  49450. {
  49451. $next = $this->match;
  49452. if (\strlen($next) < 20) {
  49453. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  49454. }
  49455. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  49456. }
  49457. public function getFullUpcomingInput()
  49458. {
  49459. $next = $this->match;
  49460. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  49461. $len = \strlen($this->input);
  49462. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  49463. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  49464. } elseif (\strlen($next) < 20) {
  49465. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  49466. }
  49467. return $next;
  49468. }
  49469. protected function parseError($str, $hash)
  49470. {
  49471. throw new \Exception($str);
  49472. }
  49473. private function next()
  49474. {
  49475. if ($this->done) {
  49476. return $this->EOF;
  49477. }
  49478. if ($this->offset === \strlen($this->input)) {
  49479. $this->done = true;
  49480. }
  49481. $token = null;
  49482. $match = null;
  49483. $col = null;
  49484. $lines = null;
  49485. if (!$this->more) {
  49486. $this->yytext = '';
  49487. $this->match = '';
  49488. }
  49489. $rules = $this->getCurrentRules();
  49490. $rulesLen = \count($rules);
  49491. for ($i=0; $i < $rulesLen; $i++) {
  49492. if (preg_match($this->rules[$rules[$i]], $this->input, $match, 0, $this->offset)) {
  49493. preg_match_all('/\n.*/', $match[0], $lines);
  49494. $lines = $lines[0];
  49495. if ($lines) {
  49496. $this->yylineno += \count($lines);
  49497. }
  49498. $this->yylloc = array(
  49499. 'first_line' => $this->yylloc['last_line'],
  49500. 'last_line' => $this->yylineno+1,
  49501. 'first_column' => $this->yylloc['last_column'],
  49502. 'last_column' => $lines ? \strlen($lines[\count($lines) - 1]) - 1 : $this->yylloc['last_column'] + \strlen($match[0]),
  49503. );
  49504. $this->yytext .= $match[0];
  49505. $this->match .= $match[0];
  49506. $this->yyleng = \strlen($this->yytext);
  49507. $this->more = false;
  49508. $this->offset += \strlen($match[0]);
  49509. $token = $this->performAction($rules[$i], $this->conditionStack[\count($this->conditionStack)-1]);
  49510. if ($token) {
  49511. return $token;
  49512. }
  49513. return new Undefined();
  49514. }
  49515. }
  49516. if ($this->offset === \strlen($this->input)) {
  49517. return $this->EOF;
  49518. }
  49519. $this->parseError(
  49520. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition(),
  49521. array(
  49522. 'text' => "",
  49523. 'token' => null,
  49524. 'line' => $this->yylineno,
  49525. )
  49526. );
  49527. }
  49528. private function getCurrentRules()
  49529. {
  49530. return $this->conditions[$this->conditionStack[\count($this->conditionStack)-1]]['rules'];
  49531. }
  49532. private function performAction($avoiding_name_collisions, $YY_START)
  49533. {
  49534. switch ($avoiding_name_collisions) {
  49535. case 0:
  49536. break;
  49537. case 1:
  49538. return 6;
  49539. case 2:
  49540. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  49541. return 4;
  49542. case 3:
  49543. return 17;
  49544. case 4:
  49545. return 18;
  49546. case 5:
  49547. return 23;
  49548. case 6:
  49549. return 24;
  49550. case 7:
  49551. return 22;
  49552. case 8:
  49553. return 21;
  49554. case 9:
  49555. return 10;
  49556. case 10:
  49557. return 11;
  49558. case 11:
  49559. return 8;
  49560. case 12:
  49561. return 14;
  49562. case 13:
  49563. return 'INVALID';
  49564. }
  49565. }
  49566. }
  49567. <?php
  49568. namespace Seld\JsonLint;
  49569. class ParsingException extends \Exception
  49570. {
  49571. protected $details;
  49572. public function __construct($message, $details = array())
  49573. {
  49574. $this->details = $details;
  49575. parent::__construct($message);
  49576. }
  49577. public function getDetails()
  49578. {
  49579. return $this->details;
  49580. }
  49581. }
  49582. <?php
  49583. namespace Seld\JsonLint;
  49584. class Undefined
  49585. {
  49586. }
  49587. Copyright (c) 2015 Jordi Boggiano
  49588. Permission is hereby granted, free of charge, to any person obtaining a copy
  49589. of this software and associated documentation files (the "Software"), to deal
  49590. in the Software without restriction, including without limitation the rights
  49591. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  49592. copies of the Software, and to permit persons to whom the Software is furnished
  49593. to do so, subject to the following conditions:
  49594. The above copyright notice and this permission notice shall be included in all
  49595. copies or substantial portions of the Software.
  49596. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  49597. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  49598. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  49599. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  49600. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  49601. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  49602. THE SOFTWARE.
  49603. <?php
  49604. namespace Seld\PharUtils;
  49605. class Linter
  49606. {
  49607. public static function lint($path)
  49608. {
  49609. $php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
  49610. if ($isWindows = defined('PHP_WINDOWS_VERSION_BUILD')) {
  49611. $tmpFile = @tempnam(sys_get_temp_dir(), '');
  49612. if (!$tmpFile || !is_writable($tmpFile)) {
  49613. throw new \RuntimeException('Unable to create temp file');
  49614. }
  49615. $php = self::escapeWindowsPath($php);
  49616. $tmpFile = self::escapeWindowsPath($tmpFile);
  49617. if (PHP_VERSION_ID >= 80000) {
  49618. $format = '%s -l %s';
  49619. } else {
  49620. $format = '"%s -l %s"';
  49621. }
  49622. $command = sprintf($format, $php, $tmpFile);
  49623. } else {
  49624. $command = "'".$php."' -l";
  49625. }
  49626. $descriptorspec = array(
  49627. 0 => array('pipe', 'r'),
  49628. 1 => array('pipe', 'w'),
  49629. 2 => array('pipe', 'w')
  49630. );
  49631. foreach (new \RecursiveIteratorIterator(new \Phar($path)) as $file) {
  49632. if ($file->isDir()) {
  49633. continue;
  49634. }
  49635. if (substr($file, -4) === '.php') {
  49636. $filename = (string) $file;
  49637. if ($isWindows) {
  49638. file_put_contents($tmpFile, file_get_contents($filename));
  49639. }
  49640. $process = proc_open($command, $descriptorspec, $pipes);
  49641. if (is_resource($process)) {
  49642. if (!$isWindows) {
  49643. fwrite($pipes[0], file_get_contents($filename));
  49644. }
  49645. fclose($pipes[0]);
  49646. $stdout = stream_get_contents($pipes[1]);
  49647. fclose($pipes[1]);
  49648. $stderr = stream_get_contents($pipes[2]);
  49649. fclose($pipes[2]);
  49650. $exitCode = proc_close($process);
  49651. if ($exitCode !== 0) {
  49652. if ($isWindows) {
  49653. $stderr = str_replace($tmpFile, $filename, $stderr);
  49654. }
  49655. throw new \UnexpectedValueException('Failed linting '.$file.': '.$stderr);
  49656. }
  49657. } else {
  49658. throw new \RuntimeException('Could not start linter process');
  49659. }
  49660. }
  49661. }
  49662. if ($isWindows) {
  49663. @unlink($tmpFile);
  49664. }
  49665. }
  49666. private static function escapeWindowsPath($path)
  49667. {
  49668. if (strpbrk($path, " ()") !== false) {
  49669. $path = '"'.$path.'"';
  49670. }
  49671. return $path;
  49672. }
  49673. }
  49674. <?php
  49675. namespace Seld\PharUtils;
  49676. class Timestamps
  49677. {
  49678. private $contents;
  49679. public function __construct($file)
  49680. {
  49681. $this->contents = file_get_contents($file);
  49682. }
  49683. public function updateTimestamps($timestamp = null)
  49684. {
  49685. if ($timestamp instanceof \DateTime || $timestamp instanceof \DateTimeInterface) {
  49686. $timestamp = $timestamp->getTimestamp();
  49687. } elseif (is_string($timestamp)) {
  49688. $timestamp = strtotime($timestamp);
  49689. } elseif (!is_int($timestamp)) {
  49690. $timestamp = strtotime('1984-12-24T00:00:00Z');
  49691. }
  49692. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  49693. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  49694. }
  49695. $pos = $match[0][1] + strlen($match[0][0]);
  49696. $stubEnd = $pos + $this->readUint($pos, 4);
  49697. $pos += 4;
  49698. $numFiles = $this->readUint($pos, 4);
  49699. $pos += 4;
  49700. $pos += 2;
  49701. $pos += 4;
  49702. $aliasLength = $this->readUint($pos, 4);
  49703. $pos += 4 + $aliasLength;
  49704. $metadataLength = $this->readUint($pos, 4);
  49705. $pos += 4 + $metadataLength;
  49706. while ($pos < $stubEnd) {
  49707. $filenameLength = $this->readUint($pos, 4);
  49708. $pos += 4 + $filenameLength;
  49709. $pos += 4;
  49710. $this->contents = substr_replace($this->contents, pack('L', $timestamp), $pos, 4);
  49711. $pos += 4*4;
  49712. $metadataLength = $this->readUint($pos, 4);
  49713. $pos += 4 + $metadataLength;
  49714. $numFiles--;
  49715. }
  49716. if ($numFiles !== 0) {
  49717. throw new \LogicException('All files were not processed, something must have gone wrong');
  49718. }
  49719. }
  49720. public function save($path, $signatureAlgo)
  49721. {
  49722. $pos = $this->determineSignatureBegin();
  49723. $algos = array(
  49724. \Phar::MD5 => 'md5',
  49725. \Phar::SHA1 => 'sha1',
  49726. \Phar::SHA256 => 'sha256',
  49727. \Phar::SHA512 => 'sha512',
  49728. );
  49729. if (!isset($algos[$signatureAlgo])) {
  49730. throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
  49731. }
  49732. $algo = $algos[$signatureAlgo];
  49733. $signature = hash($algo, substr($this->contents, 0, $pos), true)
  49734. . pack('L', $signatureAlgo)
  49735. . 'GBMB';
  49736. $this->contents = substr($this->contents, 0, $pos) . $signature;
  49737. return file_put_contents($path, $this->contents);
  49738. }
  49739. private function readUint($pos, $bytes)
  49740. {
  49741. $res = unpack('V', substr($this->contents, $pos, $bytes));
  49742. return $res[1];
  49743. }
  49744. private function determineSignatureBegin()
  49745. {
  49746. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  49747. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  49748. }
  49749. $pos = $match[0][1] + strlen($match[0][0]);
  49750. $manifestEnd = $pos + 4 + $this->readUint($pos, 4);
  49751. $pos += 4;
  49752. $numFiles = $this->readUint($pos, 4);
  49753. $pos += 4;
  49754. $pos += 2;
  49755. $pos += 4;
  49756. $aliasLength = $this->readUint($pos, 4);
  49757. $pos += 4 + $aliasLength;
  49758. $metadataLength = $this->readUint($pos, 4);
  49759. $pos += 4 + $metadataLength;
  49760. $compressedSizes = 0;
  49761. while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
  49762. $filenameLength = $this->readUint($pos, 4);
  49763. $pos += 4 + $filenameLength;
  49764. $pos += 2*4;
  49765. $compressedSizes += $this->readUint($pos, 4);
  49766. $pos += 3*4;
  49767. $metadataLength = $this->readUint($pos, 4);
  49768. $pos += 4 + $metadataLength;
  49769. $numFiles--;
  49770. }
  49771. if ($numFiles !== 0) {
  49772. throw new \LogicException('All files were not processed, something must have gone wrong');
  49773. }
  49774. return $manifestEnd + $compressedSizes;
  49775. }
  49776. }
  49777. <?php
  49778. namespace Symfony\Component\Console;
  49779. use Symfony\Component\Console\Command\Command;
  49780. use Symfony\Component\Console\Command\HelpCommand;
  49781. use Symfony\Component\Console\Command\ListCommand;
  49782. use Symfony\Component\Console\Descriptor\TextDescriptor;
  49783. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  49784. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  49785. use Symfony\Component\Console\Event\ConsoleExceptionEvent;
  49786. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  49787. use Symfony\Component\Console\Exception\CommandNotFoundException;
  49788. use Symfony\Component\Console\Exception\ExceptionInterface;
  49789. use Symfony\Component\Console\Exception\LogicException;
  49790. use Symfony\Component\Console\Formatter\OutputFormatter;
  49791. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  49792. use Symfony\Component\Console\Helper\DialogHelper;
  49793. use Symfony\Component\Console\Helper\FormatterHelper;
  49794. use Symfony\Component\Console\Helper\Helper;
  49795. use Symfony\Component\Console\Helper\HelperSet;
  49796. use Symfony\Component\Console\Helper\ProcessHelper;
  49797. use Symfony\Component\Console\Helper\ProgressHelper;
  49798. use Symfony\Component\Console\Helper\QuestionHelper;
  49799. use Symfony\Component\Console\Helper\TableHelper;
  49800. use Symfony\Component\Console\Input\ArgvInput;
  49801. use Symfony\Component\Console\Input\ArrayInput;
  49802. use Symfony\Component\Console\Input\InputArgument;
  49803. use Symfony\Component\Console\Input\InputAwareInterface;
  49804. use Symfony\Component\Console\Input\InputDefinition;
  49805. use Symfony\Component\Console\Input\InputInterface;
  49806. use Symfony\Component\Console\Input\InputOption;
  49807. use Symfony\Component\Console\Output\BufferedOutput;
  49808. use Symfony\Component\Console\Output\ConsoleOutput;
  49809. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  49810. use Symfony\Component\Console\Output\OutputInterface;
  49811. use Symfony\Component\Debug\Exception\FatalThrowableError;
  49812. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  49813. class Application
  49814. {
  49815. private $commands = array();
  49816. private $wantHelps = false;
  49817. private $runningCommand;
  49818. private $name;
  49819. private $version;
  49820. private $catchExceptions = true;
  49821. private $autoExit = true;
  49822. private $definition;
  49823. private $helperSet;
  49824. private $dispatcher;
  49825. private $terminalDimensions;
  49826. private $defaultCommand;
  49827. private $initialized;
  49828. public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
  49829. {
  49830. $this->name = $name;
  49831. $this->version = $version;
  49832. $this->defaultCommand = 'list';
  49833. }
  49834. public function setDispatcher(EventDispatcherInterface $dispatcher)
  49835. {
  49836. $this->dispatcher = $dispatcher;
  49837. }
  49838. public function run(InputInterface $input = null, OutputInterface $output = null)
  49839. {
  49840. if (null === $input) {
  49841. $input = new ArgvInput();
  49842. }
  49843. if (null === $output) {
  49844. $output = new ConsoleOutput();
  49845. }
  49846. $this->configureIO($input, $output);
  49847. try {
  49848. $e = null;
  49849. $exitCode = $this->doRun($input, $output);
  49850. } catch (\Exception $e) {
  49851. }
  49852. if (null !== $e) {
  49853. if (!$this->catchExceptions) {
  49854. throw $e;
  49855. }
  49856. if ($output instanceof ConsoleOutputInterface) {
  49857. $this->renderException($e, $output->getErrorOutput());
  49858. } else {
  49859. $this->renderException($e, $output);
  49860. }
  49861. $exitCode = $this->getExitCodeForThrowable($e);
  49862. }
  49863. if ($this->autoExit) {
  49864. if ($exitCode > 255) {
  49865. $exitCode = 255;
  49866. }
  49867. exit($exitCode);
  49868. }
  49869. return $exitCode;
  49870. }
  49871. public function doRun(InputInterface $input, OutputInterface $output)
  49872. {
  49873. if (true === $input->hasParameterOption(array('--version', '-V'))) {
  49874. $output->writeln($this->getLongVersion());
  49875. return 0;
  49876. }
  49877. $name = $this->getCommandName($input);
  49878. if (true === $input->hasParameterOption(array('--help', '-h'))) {
  49879. if (!$name) {
  49880. $name = 'help';
  49881. $input = new ArrayInput(array('command' => 'help'));
  49882. } else {
  49883. $this->wantHelps = true;
  49884. }
  49885. }
  49886. if (!$name) {
  49887. $name = $this->defaultCommand;
  49888. $definition = $this->getDefinition();
  49889. $definition->setArguments(array_merge(
  49890. $definition->getArguments(),
  49891. array(
  49892. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  49893. )
  49894. ));
  49895. }
  49896. $this->runningCommand = null;
  49897. $command = $this->find($name);
  49898. $this->runningCommand = $command;
  49899. $exitCode = $this->doRunCommand($command, $input, $output);
  49900. $this->runningCommand = null;
  49901. return $exitCode;
  49902. }
  49903. public function setHelperSet(HelperSet $helperSet)
  49904. {
  49905. $this->helperSet = $helperSet;
  49906. }
  49907. public function getHelperSet()
  49908. {
  49909. if (!$this->helperSet) {
  49910. $this->helperSet = $this->getDefaultHelperSet();
  49911. }
  49912. return $this->helperSet;
  49913. }
  49914. public function setDefinition(InputDefinition $definition)
  49915. {
  49916. $this->definition = $definition;
  49917. }
  49918. public function getDefinition()
  49919. {
  49920. if (!$this->definition) {
  49921. $this->definition = $this->getDefaultInputDefinition();
  49922. }
  49923. return $this->definition;
  49924. }
  49925. public function getHelp()
  49926. {
  49927. return $this->getLongVersion();
  49928. }
  49929. public function setCatchExceptions($boolean)
  49930. {
  49931. $this->catchExceptions = (bool) $boolean;
  49932. }
  49933. public function setAutoExit($boolean)
  49934. {
  49935. $this->autoExit = (bool) $boolean;
  49936. }
  49937. public function getName()
  49938. {
  49939. return $this->name;
  49940. }
  49941. public function setName($name)
  49942. {
  49943. $this->name = $name;
  49944. }
  49945. public function getVersion()
  49946. {
  49947. return $this->version;
  49948. }
  49949. public function setVersion($version)
  49950. {
  49951. $this->version = $version;
  49952. }
  49953. public function getLongVersion()
  49954. {
  49955. if ('UNKNOWN' !== $this->getName()) {
  49956. if ('UNKNOWN' !== $this->getVersion()) {
  49957. return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
  49958. }
  49959. return sprintf('<info>%s</info>', $this->getName());
  49960. }
  49961. return '<info>Console Tool</info>';
  49962. }
  49963. public function register($name)
  49964. {
  49965. return $this->add(new Command($name));
  49966. }
  49967. public function addCommands(array $commands)
  49968. {
  49969. foreach ($commands as $command) {
  49970. $this->add($command);
  49971. }
  49972. }
  49973. public function add(Command $command)
  49974. {
  49975. $this->init();
  49976. $command->setApplication($this);
  49977. if (!$command->isEnabled()) {
  49978. $command->setApplication(null);
  49979. return;
  49980. }
  49981. if (null === $command->getDefinition()) {
  49982. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
  49983. }
  49984. $this->commands[$command->getName()] = $command;
  49985. foreach ($command->getAliases() as $alias) {
  49986. $this->commands[$alias] = $command;
  49987. }
  49988. return $command;
  49989. }
  49990. public function get($name)
  49991. {
  49992. $this->init();
  49993. if (!isset($this->commands[$name])) {
  49994. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  49995. }
  49996. $command = $this->commands[$name];
  49997. if ($this->wantHelps) {
  49998. $this->wantHelps = false;
  49999. $helpCommand = $this->get('help');
  50000. $helpCommand->setCommand($command);
  50001. return $helpCommand;
  50002. }
  50003. return $command;
  50004. }
  50005. public function has($name)
  50006. {
  50007. $this->init();
  50008. return isset($this->commands[$name]);
  50009. }
  50010. public function getNamespaces()
  50011. {
  50012. $namespaces = array();
  50013. foreach ($this->all() as $command) {
  50014. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
  50015. foreach ($command->getAliases() as $alias) {
  50016. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias));
  50017. }
  50018. }
  50019. return array_values(array_unique(array_filter($namespaces)));
  50020. }
  50021. public function findNamespace($namespace)
  50022. {
  50023. $allNamespaces = $this->getNamespaces();
  50024. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
  50025. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  50026. if (empty($namespaces)) {
  50027. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  50028. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  50029. if (1 == \count($alternatives)) {
  50030. $message .= "\n\nDid you mean this?\n ";
  50031. } else {
  50032. $message .= "\n\nDid you mean one of these?\n ";
  50033. }
  50034. $message .= implode("\n ", $alternatives);
  50035. }
  50036. throw new CommandNotFoundException($message, $alternatives);
  50037. }
  50038. $exact = \in_array($namespace, $namespaces, true);
  50039. if (\count($namespaces) > 1 && !$exact) {
  50040. throw new CommandNotFoundException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
  50041. }
  50042. return $exact ? $namespace : reset($namespaces);
  50043. }
  50044. public function find($name)
  50045. {
  50046. $this->init();
  50047. $aliases = array();
  50048. $allCommands = array_keys($this->commands);
  50049. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
  50050. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  50051. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
  50052. if (false !== $pos = strrpos($name, ':')) {
  50053. $this->findNamespace(substr($name, 0, $pos));
  50054. }
  50055. $message = sprintf('Command "%s" is not defined.', $name);
  50056. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  50057. if (1 == \count($alternatives)) {
  50058. $message .= "\n\nDid you mean this?\n ";
  50059. } else {
  50060. $message .= "\n\nDid you mean one of these?\n ";
  50061. }
  50062. $message .= implode("\n ", $alternatives);
  50063. }
  50064. throw new CommandNotFoundException($message, $alternatives);
  50065. }
  50066. if (\count($commands) > 1) {
  50067. $commandList = $this->commands;
  50068. $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
  50069. $commandName = $commandList[$nameOrAlias]->getName();
  50070. $aliases[$nameOrAlias] = $commandName;
  50071. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  50072. });
  50073. }
  50074. $exact = \in_array($name, $commands, true) || isset($aliases[$name]);
  50075. if (!$exact && \count($commands) > 1) {
  50076. $suggestions = $this->getAbbreviationSuggestions(array_values($commands));
  50077. throw new CommandNotFoundException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions), array_values($commands));
  50078. }
  50079. return $this->get($exact ? $name : reset($commands));
  50080. }
  50081. public function all($namespace = null)
  50082. {
  50083. $this->init();
  50084. if (null === $namespace) {
  50085. return $this->commands;
  50086. }
  50087. $commands = array();
  50088. foreach ($this->commands as $name => $command) {
  50089. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  50090. $commands[$name] = $command;
  50091. }
  50092. }
  50093. return $commands;
  50094. }
  50095. public static function getAbbreviations($names)
  50096. {
  50097. $abbrevs = array();
  50098. foreach ($names as $name) {
  50099. for ($len = \strlen($name); $len > 0; --$len) {
  50100. $abbrev = substr($name, 0, $len);
  50101. $abbrevs[$abbrev][] = $name;
  50102. }
  50103. }
  50104. return $abbrevs;
  50105. }
  50106. public function asText($namespace = null, $raw = false)
  50107. {
  50108. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  50109. $descriptor = new TextDescriptor();
  50110. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, !$raw);
  50111. $descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true));
  50112. return $output->fetch();
  50113. }
  50114. public function asXml($namespace = null, $asDom = false)
  50115. {
  50116. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  50117. $descriptor = new XmlDescriptor();
  50118. if ($asDom) {
  50119. return $descriptor->getApplicationDocument($this, $namespace);
  50120. }
  50121. $output = new BufferedOutput();
  50122. $descriptor->describe($output, $this, array('namespace' => $namespace));
  50123. return $output->fetch();
  50124. }
  50125. public function renderException($e, $output)
  50126. {
  50127. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  50128. do {
  50129. $title = sprintf(' [%s] ', \get_class($e));
  50130. $len = Helper::strlen($title);
  50131. $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
  50132. if (\defined('HHVM_VERSION') && $width > 1 << 31) {
  50133. $width = 1 << 31;
  50134. }
  50135. $lines = array();
  50136. foreach (preg_split('/\r?\n/', trim($e->getMessage())) as $line) {
  50137. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  50138. $lineLength = Helper::strlen($line) + 4;
  50139. $lines[] = array($line, $lineLength);
  50140. $len = max($lineLength, $len);
  50141. }
  50142. }
  50143. $messages = array();
  50144. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  50145. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
  50146. foreach ($lines as $line) {
  50147. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  50148. }
  50149. $messages[] = $emptyLine;
  50150. $messages[] = '';
  50151. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  50152. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  50153. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  50154. $trace = $e->getTrace();
  50155. array_unshift($trace, array(
  50156. 'function' => '',
  50157. 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
  50158. 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
  50159. 'args' => array(),
  50160. ));
  50161. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  50162. $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
  50163. $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
  50164. $function = $trace[$i]['function'];
  50165. $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
  50166. $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
  50167. $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET);
  50168. }
  50169. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  50170. }
  50171. } while ($e = $e->getPrevious());
  50172. if (null !== $this->runningCommand) {
  50173. $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
  50174. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  50175. }
  50176. }
  50177. protected function getTerminalWidth()
  50178. {
  50179. $dimensions = $this->getTerminalDimensions();
  50180. return $dimensions[0];
  50181. }
  50182. protected function getTerminalHeight()
  50183. {
  50184. $dimensions = $this->getTerminalDimensions();
  50185. return $dimensions[1];
  50186. }
  50187. public function getTerminalDimensions()
  50188. {
  50189. if ($this->terminalDimensions) {
  50190. return $this->terminalDimensions;
  50191. }
  50192. if ('\\' === \DIRECTORY_SEPARATOR) {
  50193. if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
  50194. return array((int) $matches[1], (int) $matches[2]);
  50195. }
  50196. if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
  50197. return array((int) $matches[1], (int) $matches[2]);
  50198. }
  50199. }
  50200. if ($sttyString = $this->getSttyColumns()) {
  50201. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  50202. return array((int) $matches[2], (int) $matches[1]);
  50203. }
  50204. if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  50205. return array((int) $matches[2], (int) $matches[1]);
  50206. }
  50207. }
  50208. return array(null, null);
  50209. }
  50210. public function setTerminalDimensions($width, $height)
  50211. {
  50212. $this->terminalDimensions = array($width, $height);
  50213. return $this;
  50214. }
  50215. protected function configureIO(InputInterface $input, OutputInterface $output)
  50216. {
  50217. if (true === $input->hasParameterOption(array('--ansi'))) {
  50218. $output->setDecorated(true);
  50219. } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
  50220. $output->setDecorated(false);
  50221. }
  50222. if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
  50223. $input->setInteractive(false);
  50224. } elseif (\function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
  50225. $inputStream = $this->getHelperSet()->get('question')->getInputStream();
  50226. if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
  50227. $input->setInteractive(false);
  50228. }
  50229. }
  50230. if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
  50231. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  50232. $input->setInteractive(false);
  50233. } else {
  50234. if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
  50235. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  50236. } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
  50237. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  50238. } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
  50239. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  50240. }
  50241. }
  50242. }
  50243. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  50244. {
  50245. foreach ($command->getHelperSet() as $helper) {
  50246. if ($helper instanceof InputAwareInterface) {
  50247. $helper->setInput($input);
  50248. }
  50249. }
  50250. if (null === $this->dispatcher) {
  50251. return $command->run($input, $output);
  50252. }
  50253. try {
  50254. $command->mergeApplicationDefinition();
  50255. $input->bind($command->getDefinition());
  50256. } catch (ExceptionInterface $e) {
  50257. }
  50258. $event = new ConsoleCommandEvent($command, $input, $output);
  50259. $e = null;
  50260. try {
  50261. $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
  50262. if ($event->commandShouldRun()) {
  50263. $exitCode = $command->run($input, $output);
  50264. } else {
  50265. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  50266. }
  50267. } catch (\Exception $e) {
  50268. } catch (\Throwable $e) {
  50269. }
  50270. if (null !== $e) {
  50271. $x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
  50272. $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
  50273. $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
  50274. if ($x !== $event->getException()) {
  50275. $e = $event->getException();
  50276. }
  50277. $exitCode = $this->getExitCodeForThrowable($e);
  50278. }
  50279. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  50280. $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
  50281. if (null !== $e) {
  50282. throw $e;
  50283. }
  50284. return $event->getExitCode();
  50285. }
  50286. protected function getCommandName(InputInterface $input)
  50287. {
  50288. return $input->getFirstArgument();
  50289. }
  50290. protected function getDefaultInputDefinition()
  50291. {
  50292. return new InputDefinition(array(
  50293. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  50294. new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
  50295. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  50296. 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'),
  50297. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  50298. new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
  50299. new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
  50300. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  50301. ));
  50302. }
  50303. protected function getDefaultCommands()
  50304. {
  50305. return array(new HelpCommand(), new ListCommand());
  50306. }
  50307. protected function getDefaultHelperSet()
  50308. {
  50309. return new HelperSet(array(
  50310. new FormatterHelper(),
  50311. new DialogHelper(false),
  50312. new ProgressHelper(false),
  50313. new TableHelper(false),
  50314. new DebugFormatterHelper(),
  50315. new ProcessHelper(),
  50316. new QuestionHelper(),
  50317. ));
  50318. }
  50319. private function getSttyColumns()
  50320. {
  50321. if (!\function_exists('proc_open')) {
  50322. return;
  50323. }
  50324. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  50325. $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  50326. if (\is_resource($process)) {
  50327. $info = stream_get_contents($pipes[1]);
  50328. fclose($pipes[1]);
  50329. fclose($pipes[2]);
  50330. proc_close($process);
  50331. return $info;
  50332. }
  50333. }
  50334. private function getConsoleMode()
  50335. {
  50336. if (!\function_exists('proc_open')) {
  50337. return;
  50338. }
  50339. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  50340. $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  50341. if (\is_resource($process)) {
  50342. $info = stream_get_contents($pipes[1]);
  50343. fclose($pipes[1]);
  50344. fclose($pipes[2]);
  50345. proc_close($process);
  50346. if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  50347. return $matches[2].'x'.$matches[1];
  50348. }
  50349. }
  50350. }
  50351. private function getAbbreviationSuggestions($abbrevs)
  50352. {
  50353. return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], \count($abbrevs) > 2 ? sprintf(' and %d more', \count($abbrevs) - 2) : '');
  50354. }
  50355. public function extractNamespace($name, $limit = null)
  50356. {
  50357. $parts = explode(':', $name);
  50358. array_pop($parts);
  50359. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  50360. }
  50361. private function findAlternatives($name, $collection)
  50362. {
  50363. $threshold = 1e3;
  50364. $alternatives = array();
  50365. $collectionParts = array();
  50366. foreach ($collection as $item) {
  50367. $collectionParts[$item] = explode(':', $item);
  50368. }
  50369. foreach (explode(':', $name) as $i => $subname) {
  50370. foreach ($collectionParts as $collectionName => $parts) {
  50371. $exists = isset($alternatives[$collectionName]);
  50372. if (!isset($parts[$i]) && $exists) {
  50373. $alternatives[$collectionName] += $threshold;
  50374. continue;
  50375. } elseif (!isset($parts[$i])) {
  50376. continue;
  50377. }
  50378. $lev = levenshtein($subname, $parts[$i]);
  50379. if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
  50380. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  50381. } elseif ($exists) {
  50382. $alternatives[$collectionName] += $threshold;
  50383. }
  50384. }
  50385. }
  50386. foreach ($collection as $item) {
  50387. $lev = levenshtein($name, $item);
  50388. if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
  50389. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  50390. }
  50391. }
  50392. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  50393. asort($alternatives);
  50394. return array_keys($alternatives);
  50395. }
  50396. public function setDefaultCommand($commandName)
  50397. {
  50398. $this->defaultCommand = $commandName;
  50399. }
  50400. private function splitStringByWidth($string, $width)
  50401. {
  50402. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  50403. return str_split($string, $width);
  50404. }
  50405. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  50406. $lines = array();
  50407. $line = '';
  50408. foreach (preg_split('//u', $utf8String) as $char) {
  50409. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  50410. $line .= $char;
  50411. continue;
  50412. }
  50413. $lines[] = str_pad($line, $width);
  50414. $line = $char;
  50415. }
  50416. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  50417. mb_convert_variables($encoding, 'utf8', $lines);
  50418. return $lines;
  50419. }
  50420. private function extractAllNamespaces($name)
  50421. {
  50422. $parts = explode(':', $name, -1);
  50423. $namespaces = array();
  50424. foreach ($parts as $part) {
  50425. if (\count($namespaces)) {
  50426. $namespaces[] = end($namespaces).':'.$part;
  50427. } else {
  50428. $namespaces[] = $part;
  50429. }
  50430. }
  50431. return $namespaces;
  50432. }
  50433. private function init()
  50434. {
  50435. if ($this->initialized) {
  50436. return;
  50437. }
  50438. $this->initialized = true;
  50439. foreach ($this->getDefaultCommands() as $command) {
  50440. $this->add($command);
  50441. }
  50442. }
  50443. private function getExitCodeForThrowable($throwable)
  50444. {
  50445. $exitCode = $throwable->getCode();
  50446. if (is_numeric($exitCode)) {
  50447. $exitCode = (int) $exitCode;
  50448. if (0 === $exitCode) {
  50449. $exitCode = 1;
  50450. }
  50451. } else {
  50452. $exitCode = 1;
  50453. }
  50454. return $exitCode;
  50455. }
  50456. }
  50457. <?php
  50458. namespace Symfony\Component\Console\Command;
  50459. use Symfony\Component\Console\Application;
  50460. use Symfony\Component\Console\Descriptor\TextDescriptor;
  50461. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  50462. use Symfony\Component\Console\Exception\ExceptionInterface;
  50463. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50464. use Symfony\Component\Console\Exception\LogicException;
  50465. use Symfony\Component\Console\Helper\HelperSet;
  50466. use Symfony\Component\Console\Input\InputArgument;
  50467. use Symfony\Component\Console\Input\InputDefinition;
  50468. use Symfony\Component\Console\Input\InputInterface;
  50469. use Symfony\Component\Console\Input\InputOption;
  50470. use Symfony\Component\Console\Output\BufferedOutput;
  50471. use Symfony\Component\Console\Output\OutputInterface;
  50472. class Command
  50473. {
  50474. private $application;
  50475. private $name;
  50476. private $processTitle;
  50477. private $aliases = array();
  50478. private $definition;
  50479. private $help;
  50480. private $description;
  50481. private $ignoreValidationErrors = false;
  50482. private $applicationDefinitionMerged = false;
  50483. private $applicationDefinitionMergedWithArgs = false;
  50484. private $code;
  50485. private $synopsis = array();
  50486. private $usages = array();
  50487. private $helperSet;
  50488. public function __construct($name = null)
  50489. {
  50490. $this->definition = new InputDefinition();
  50491. if (null !== $name) {
  50492. $this->setName($name);
  50493. }
  50494. $this->configure();
  50495. if (!$this->name) {
  50496. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
  50497. }
  50498. }
  50499. public function ignoreValidationErrors()
  50500. {
  50501. $this->ignoreValidationErrors = true;
  50502. }
  50503. public function setApplication(Application $application = null)
  50504. {
  50505. $this->application = $application;
  50506. if ($application) {
  50507. $this->setHelperSet($application->getHelperSet());
  50508. } else {
  50509. $this->helperSet = null;
  50510. }
  50511. }
  50512. public function setHelperSet(HelperSet $helperSet)
  50513. {
  50514. $this->helperSet = $helperSet;
  50515. }
  50516. public function getHelperSet()
  50517. {
  50518. return $this->helperSet;
  50519. }
  50520. public function getApplication()
  50521. {
  50522. return $this->application;
  50523. }
  50524. public function isEnabled()
  50525. {
  50526. return true;
  50527. }
  50528. protected function configure()
  50529. {
  50530. }
  50531. protected function execute(InputInterface $input, OutputInterface $output)
  50532. {
  50533. throw new LogicException('You must override the execute() method in the concrete command class.');
  50534. }
  50535. protected function interact(InputInterface $input, OutputInterface $output)
  50536. {
  50537. }
  50538. protected function initialize(InputInterface $input, OutputInterface $output)
  50539. {
  50540. }
  50541. public function run(InputInterface $input, OutputInterface $output)
  50542. {
  50543. $this->getSynopsis(true);
  50544. $this->getSynopsis(false);
  50545. $this->mergeApplicationDefinition();
  50546. try {
  50547. $input->bind($this->definition);
  50548. } catch (ExceptionInterface $e) {
  50549. if (!$this->ignoreValidationErrors) {
  50550. throw $e;
  50551. }
  50552. }
  50553. $this->initialize($input, $output);
  50554. if (null !== $this->processTitle) {
  50555. if (\function_exists('cli_set_process_title')) {
  50556. if (!@cli_set_process_title($this->processTitle)) {
  50557. if ('Darwin' === PHP_OS) {
  50558. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  50559. } else {
  50560. cli_set_process_title($this->processTitle);
  50561. }
  50562. }
  50563. } elseif (\function_exists('setproctitle')) {
  50564. setproctitle($this->processTitle);
  50565. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  50566. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  50567. }
  50568. }
  50569. if ($input->isInteractive()) {
  50570. $this->interact($input, $output);
  50571. }
  50572. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  50573. $input->setArgument('command', $this->getName());
  50574. }
  50575. $input->validate();
  50576. if ($this->code) {
  50577. $statusCode = \call_user_func($this->code, $input, $output);
  50578. } else {
  50579. $statusCode = $this->execute($input, $output);
  50580. }
  50581. return is_numeric($statusCode) ? (int) $statusCode : 0;
  50582. }
  50583. public function setCode($code)
  50584. {
  50585. if (!\is_callable($code)) {
  50586. throw new InvalidArgumentException('Invalid callable provided to Command::setCode.');
  50587. }
  50588. if (\PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
  50589. $r = new \ReflectionFunction($code);
  50590. if (null === $r->getClosureThis()) {
  50591. if (\PHP_VERSION_ID < 70000) {
  50592. $code = @\Closure::bind($code, $this);
  50593. } else {
  50594. $code = \Closure::bind($code, $this);
  50595. }
  50596. }
  50597. }
  50598. $this->code = $code;
  50599. return $this;
  50600. }
  50601. public function mergeApplicationDefinition($mergeArgs = true)
  50602. {
  50603. if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
  50604. return;
  50605. }
  50606. $this->definition->addOptions($this->application->getDefinition()->getOptions());
  50607. $this->applicationDefinitionMerged = true;
  50608. if ($mergeArgs) {
  50609. $currentArguments = $this->definition->getArguments();
  50610. $this->definition->setArguments($this->application->getDefinition()->getArguments());
  50611. $this->definition->addArguments($currentArguments);
  50612. $this->applicationDefinitionMergedWithArgs = true;
  50613. }
  50614. }
  50615. public function setDefinition($definition)
  50616. {
  50617. if ($definition instanceof InputDefinition) {
  50618. $this->definition = $definition;
  50619. } else {
  50620. $this->definition->setDefinition($definition);
  50621. }
  50622. $this->applicationDefinitionMerged = false;
  50623. return $this;
  50624. }
  50625. public function getDefinition()
  50626. {
  50627. return $this->definition;
  50628. }
  50629. public function getNativeDefinition()
  50630. {
  50631. return $this->getDefinition();
  50632. }
  50633. public function addArgument($name, $mode = null, $description = '', $default = null)
  50634. {
  50635. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  50636. return $this;
  50637. }
  50638. public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
  50639. {
  50640. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  50641. return $this;
  50642. }
  50643. public function setName($name)
  50644. {
  50645. $this->validateName($name);
  50646. $this->name = $name;
  50647. return $this;
  50648. }
  50649. public function setProcessTitle($title)
  50650. {
  50651. $this->processTitle = $title;
  50652. return $this;
  50653. }
  50654. public function getName()
  50655. {
  50656. return $this->name;
  50657. }
  50658. public function setDescription($description)
  50659. {
  50660. $this->description = $description;
  50661. return $this;
  50662. }
  50663. public function getDescription()
  50664. {
  50665. return $this->description;
  50666. }
  50667. public function setHelp($help)
  50668. {
  50669. $this->help = $help;
  50670. return $this;
  50671. }
  50672. public function getHelp()
  50673. {
  50674. return $this->help;
  50675. }
  50676. public function getProcessedHelp()
  50677. {
  50678. $name = $this->name;
  50679. $placeholders = array(
  50680. '%command.name%',
  50681. '%command.full_name%',
  50682. );
  50683. $replacements = array(
  50684. $name,
  50685. $_SERVER['PHP_SELF'].' '.$name,
  50686. );
  50687. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  50688. }
  50689. public function setAliases($aliases)
  50690. {
  50691. if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
  50692. throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
  50693. }
  50694. foreach ($aliases as $alias) {
  50695. $this->validateName($alias);
  50696. }
  50697. $this->aliases = $aliases;
  50698. return $this;
  50699. }
  50700. public function getAliases()
  50701. {
  50702. return $this->aliases;
  50703. }
  50704. public function getSynopsis($short = false)
  50705. {
  50706. $key = $short ? 'short' : 'long';
  50707. if (!isset($this->synopsis[$key])) {
  50708. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  50709. }
  50710. return $this->synopsis[$key];
  50711. }
  50712. public function addUsage($usage)
  50713. {
  50714. if (0 !== strpos($usage, $this->name)) {
  50715. $usage = sprintf('%s %s', $this->name, $usage);
  50716. }
  50717. $this->usages[] = $usage;
  50718. return $this;
  50719. }
  50720. public function getUsages()
  50721. {
  50722. return $this->usages;
  50723. }
  50724. public function getHelper($name)
  50725. {
  50726. if (null === $this->helperSet) {
  50727. 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));
  50728. }
  50729. return $this->helperSet->get($name);
  50730. }
  50731. public function asText()
  50732. {
  50733. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  50734. $descriptor = new TextDescriptor();
  50735. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  50736. $descriptor->describe($output, $this, array('raw_output' => true));
  50737. return $output->fetch();
  50738. }
  50739. public function asXml($asDom = false)
  50740. {
  50741. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  50742. $descriptor = new XmlDescriptor();
  50743. if ($asDom) {
  50744. return $descriptor->getCommandDocument($this);
  50745. }
  50746. $output = new BufferedOutput();
  50747. $descriptor->describe($output, $this);
  50748. return $output->fetch();
  50749. }
  50750. private function validateName($name)
  50751. {
  50752. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  50753. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  50754. }
  50755. }
  50756. }
  50757. <?php
  50758. namespace Symfony\Component\Console\Command;
  50759. use Symfony\Component\Console\Helper\DescriptorHelper;
  50760. use Symfony\Component\Console\Input\InputArgument;
  50761. use Symfony\Component\Console\Input\InputInterface;
  50762. use Symfony\Component\Console\Input\InputOption;
  50763. use Symfony\Component\Console\Output\OutputInterface;
  50764. class HelpCommand extends Command
  50765. {
  50766. private $command;
  50767. protected function configure()
  50768. {
  50769. $this->ignoreValidationErrors();
  50770. $this
  50771. ->setName('help')
  50772. ->setDefinition(array(
  50773. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  50774. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
  50775. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  50776. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  50777. ))
  50778. ->setDescription('Displays help for a command')
  50779. ->setHelp(<<<'EOF'
  50780. The <info>%command.name%</info> command displays help for a given command:
  50781. <info>php %command.full_name% list</info>
  50782. You can also output the help in other formats by using the <comment>--format</comment> option:
  50783. <info>php %command.full_name% --format=xml list</info>
  50784. To display the list of available commands, please use the <info>list</info> command.
  50785. EOF
  50786. )
  50787. ;
  50788. }
  50789. public function setCommand(Command $command)
  50790. {
  50791. $this->command = $command;
  50792. }
  50793. protected function execute(InputInterface $input, OutputInterface $output)
  50794. {
  50795. if (null === $this->command) {
  50796. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  50797. }
  50798. if ($input->getOption('xml')) {
  50799. @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);
  50800. $input->setOption('format', 'xml');
  50801. }
  50802. $helper = new DescriptorHelper();
  50803. $helper->describe($output, $this->command, array(
  50804. 'format' => $input->getOption('format'),
  50805. 'raw_text' => $input->getOption('raw'),
  50806. ));
  50807. $this->command = null;
  50808. }
  50809. }
  50810. <?php
  50811. namespace Symfony\Component\Console\Command;
  50812. use Symfony\Component\Console\Helper\DescriptorHelper;
  50813. use Symfony\Component\Console\Input\InputArgument;
  50814. use Symfony\Component\Console\Input\InputDefinition;
  50815. use Symfony\Component\Console\Input\InputInterface;
  50816. use Symfony\Component\Console\Input\InputOption;
  50817. use Symfony\Component\Console\Output\OutputInterface;
  50818. class ListCommand extends Command
  50819. {
  50820. protected function configure()
  50821. {
  50822. $this
  50823. ->setName('list')
  50824. ->setDefinition($this->createDefinition())
  50825. ->setDescription('Lists commands')
  50826. ->setHelp(<<<'EOF'
  50827. The <info>%command.name%</info> command lists all commands:
  50828. <info>php %command.full_name%</info>
  50829. You can also display the commands for a specific namespace:
  50830. <info>php %command.full_name% test</info>
  50831. You can also output the information in other formats by using the <comment>--format</comment> option:
  50832. <info>php %command.full_name% --format=xml</info>
  50833. It's also possible to get raw list of commands (useful for embedding command runner):
  50834. <info>php %command.full_name% --raw</info>
  50835. EOF
  50836. )
  50837. ;
  50838. }
  50839. public function getNativeDefinition()
  50840. {
  50841. return $this->createDefinition();
  50842. }
  50843. protected function execute(InputInterface $input, OutputInterface $output)
  50844. {
  50845. if ($input->getOption('xml')) {
  50846. @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);
  50847. $input->setOption('format', 'xml');
  50848. }
  50849. $helper = new DescriptorHelper();
  50850. $helper->describe($output, $this->getApplication(), array(
  50851. 'format' => $input->getOption('format'),
  50852. 'raw_text' => $input->getOption('raw'),
  50853. 'namespace' => $input->getArgument('namespace'),
  50854. ));
  50855. }
  50856. private function createDefinition()
  50857. {
  50858. return new InputDefinition(array(
  50859. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  50860. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'),
  50861. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  50862. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  50863. ));
  50864. }
  50865. }
  50866. <?php
  50867. namespace Symfony\Component\Console;
  50868. final class ConsoleEvents
  50869. {
  50870. const COMMAND = 'console.command';
  50871. const TERMINATE = 'console.terminate';
  50872. const EXCEPTION = 'console.exception';
  50873. }
  50874. <?php
  50875. namespace Symfony\Component\Console\Descriptor;
  50876. use Symfony\Component\Console\Application;
  50877. use Symfony\Component\Console\Command\Command;
  50878. use Symfony\Component\Console\Exception\CommandNotFoundException;
  50879. class ApplicationDescription
  50880. {
  50881. const GLOBAL_NAMESPACE = '_global';
  50882. private $application;
  50883. private $namespace;
  50884. private $namespaces;
  50885. private $commands;
  50886. private $aliases;
  50887. public function __construct(Application $application, $namespace = null)
  50888. {
  50889. $this->application = $application;
  50890. $this->namespace = $namespace;
  50891. }
  50892. public function getNamespaces()
  50893. {
  50894. if (null === $this->namespaces) {
  50895. $this->inspectApplication();
  50896. }
  50897. return $this->namespaces;
  50898. }
  50899. public function getCommands()
  50900. {
  50901. if (null === $this->commands) {
  50902. $this->inspectApplication();
  50903. }
  50904. return $this->commands;
  50905. }
  50906. public function getCommand($name)
  50907. {
  50908. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  50909. throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));
  50910. }
  50911. return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
  50912. }
  50913. private function inspectApplication()
  50914. {
  50915. $this->commands = array();
  50916. $this->namespaces = array();
  50917. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  50918. foreach ($this->sortCommands($all) as $namespace => $commands) {
  50919. $names = array();
  50920. foreach ($commands as $name => $command) {
  50921. if (!$command->getName()) {
  50922. continue;
  50923. }
  50924. if ($command->getName() === $name) {
  50925. $this->commands[$name] = $command;
  50926. } else {
  50927. $this->aliases[$name] = $command;
  50928. }
  50929. $names[] = $name;
  50930. }
  50931. $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
  50932. }
  50933. }
  50934. private function sortCommands(array $commands)
  50935. {
  50936. $namespacedCommands = array();
  50937. $globalCommands = array();
  50938. foreach ($commands as $name => $command) {
  50939. $key = $this->application->extractNamespace($name, 1);
  50940. if (!$key) {
  50941. $globalCommands['_global'][$name] = $command;
  50942. } else {
  50943. $namespacedCommands[$key][$name] = $command;
  50944. }
  50945. }
  50946. ksort($namespacedCommands);
  50947. $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
  50948. foreach ($namespacedCommands as &$commandsSet) {
  50949. ksort($commandsSet);
  50950. }
  50951. unset($commandsSet);
  50952. return $namespacedCommands;
  50953. }
  50954. }
  50955. <?php
  50956. namespace Symfony\Component\Console\Descriptor;
  50957. use Symfony\Component\Console\Application;
  50958. use Symfony\Component\Console\Command\Command;
  50959. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50960. use Symfony\Component\Console\Input\InputArgument;
  50961. use Symfony\Component\Console\Input\InputDefinition;
  50962. use Symfony\Component\Console\Input\InputOption;
  50963. use Symfony\Component\Console\Output\OutputInterface;
  50964. abstract class Descriptor implements DescriptorInterface
  50965. {
  50966. private $output;
  50967. public function describe(OutputInterface $output, $object, array $options = array())
  50968. {
  50969. $this->output = $output;
  50970. switch (true) {
  50971. case $object instanceof InputArgument:
  50972. $this->describeInputArgument($object, $options);
  50973. break;
  50974. case $object instanceof InputOption:
  50975. $this->describeInputOption($object, $options);
  50976. break;
  50977. case $object instanceof InputDefinition:
  50978. $this->describeInputDefinition($object, $options);
  50979. break;
  50980. case $object instanceof Command:
  50981. $this->describeCommand($object, $options);
  50982. break;
  50983. case $object instanceof Application:
  50984. $this->describeApplication($object, $options);
  50985. break;
  50986. default:
  50987. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
  50988. }
  50989. }
  50990. protected function write($content, $decorated = false)
  50991. {
  50992. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  50993. }
  50994. abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
  50995. abstract protected function describeInputOption(InputOption $option, array $options = array());
  50996. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
  50997. abstract protected function describeCommand(Command $command, array $options = array());
  50998. abstract protected function describeApplication(Application $application, array $options = array());
  50999. }
  51000. <?php
  51001. namespace Symfony\Component\Console\Descriptor;
  51002. use Symfony\Component\Console\Output\OutputInterface;
  51003. interface DescriptorInterface
  51004. {
  51005. public function describe(OutputInterface $output, $object, array $options = array());
  51006. }
  51007. <?php
  51008. namespace Symfony\Component\Console\Descriptor;
  51009. use Symfony\Component\Console\Application;
  51010. use Symfony\Component\Console\Command\Command;
  51011. use Symfony\Component\Console\Input\InputArgument;
  51012. use Symfony\Component\Console\Input\InputDefinition;
  51013. use Symfony\Component\Console\Input\InputOption;
  51014. class JsonDescriptor extends Descriptor
  51015. {
  51016. protected function describeInputArgument(InputArgument $argument, array $options = array())
  51017. {
  51018. $this->writeData($this->getInputArgumentData($argument), $options);
  51019. }
  51020. protected function describeInputOption(InputOption $option, array $options = array())
  51021. {
  51022. $this->writeData($this->getInputOptionData($option), $options);
  51023. }
  51024. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  51025. {
  51026. $this->writeData($this->getInputDefinitionData($definition), $options);
  51027. }
  51028. protected function describeCommand(Command $command, array $options = array())
  51029. {
  51030. $this->writeData($this->getCommandData($command), $options);
  51031. }
  51032. protected function describeApplication(Application $application, array $options = array())
  51033. {
  51034. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  51035. $description = new ApplicationDescription($application, $describedNamespace);
  51036. $commands = array();
  51037. foreach ($description->getCommands() as $command) {
  51038. $commands[] = $this->getCommandData($command);
  51039. }
  51040. $data = $describedNamespace
  51041. ? array('commands' => $commands, 'namespace' => $describedNamespace)
  51042. : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
  51043. $this->writeData($data, $options);
  51044. }
  51045. private function writeData(array $data, array $options)
  51046. {
  51047. $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
  51048. }
  51049. private function getInputArgumentData(InputArgument $argument)
  51050. {
  51051. return array(
  51052. 'name' => $argument->getName(),
  51053. 'is_required' => $argument->isRequired(),
  51054. 'is_array' => $argument->isArray(),
  51055. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  51056. 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  51057. );
  51058. }
  51059. private function getInputOptionData(InputOption $option)
  51060. {
  51061. return array(
  51062. 'name' => '--'.$option->getName(),
  51063. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  51064. 'accept_value' => $option->acceptValue(),
  51065. 'is_value_required' => $option->isValueRequired(),
  51066. 'is_multiple' => $option->isArray(),
  51067. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  51068. 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  51069. );
  51070. }
  51071. private function getInputDefinitionData(InputDefinition $definition)
  51072. {
  51073. $inputArguments = array();
  51074. foreach ($definition->getArguments() as $name => $argument) {
  51075. $inputArguments[$name] = $this->getInputArgumentData($argument);
  51076. }
  51077. $inputOptions = array();
  51078. foreach ($definition->getOptions() as $name => $option) {
  51079. $inputOptions[$name] = $this->getInputOptionData($option);
  51080. }
  51081. return array('arguments' => $inputArguments, 'options' => $inputOptions);
  51082. }
  51083. private function getCommandData(Command $command)
  51084. {
  51085. $command->getSynopsis();
  51086. $command->mergeApplicationDefinition(false);
  51087. return array(
  51088. 'name' => $command->getName(),
  51089. 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
  51090. 'description' => $command->getDescription(),
  51091. 'help' => $command->getProcessedHelp(),
  51092. 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
  51093. );
  51094. }
  51095. }
  51096. <?php
  51097. namespace Symfony\Component\Console\Descriptor;
  51098. use Symfony\Component\Console\Application;
  51099. use Symfony\Component\Console\Command\Command;
  51100. use Symfony\Component\Console\Helper\Helper;
  51101. use Symfony\Component\Console\Input\InputArgument;
  51102. use Symfony\Component\Console\Input\InputDefinition;
  51103. use Symfony\Component\Console\Input\InputOption;
  51104. class MarkdownDescriptor extends Descriptor
  51105. {
  51106. protected function describeInputArgument(InputArgument $argument, array $options = array())
  51107. {
  51108. $this->write(
  51109. '**'.$argument->getName().':**'."\n\n"
  51110. .'* Name: '.($argument->getName() ?: '<none>')."\n"
  51111. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  51112. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  51113. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
  51114. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  51115. );
  51116. }
  51117. protected function describeInputOption(InputOption $option, array $options = array())
  51118. {
  51119. $this->write(
  51120. '**'.$option->getName().':**'."\n\n"
  51121. .'* Name: `--'.$option->getName().'`'."\n"
  51122. .'* Shortcut: '.($option->getShortcut() ? '`-'.str_replace('|', '|-', $option->getShortcut()).'`' : '<none>')."\n"
  51123. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  51124. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  51125. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  51126. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
  51127. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  51128. );
  51129. }
  51130. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  51131. {
  51132. if ($showArguments = \count($definition->getArguments()) > 0) {
  51133. $this->write('### Arguments:');
  51134. foreach ($definition->getArguments() as $argument) {
  51135. $this->write("\n\n");
  51136. $this->write($this->describeInputArgument($argument));
  51137. }
  51138. }
  51139. if (\count($definition->getOptions()) > 0) {
  51140. if ($showArguments) {
  51141. $this->write("\n\n");
  51142. }
  51143. $this->write('### Options:');
  51144. foreach ($definition->getOptions() as $option) {
  51145. $this->write("\n\n");
  51146. $this->write($this->describeInputOption($option));
  51147. }
  51148. }
  51149. }
  51150. protected function describeCommand(Command $command, array $options = array())
  51151. {
  51152. $command->getSynopsis();
  51153. $command->mergeApplicationDefinition(false);
  51154. $this->write(
  51155. $command->getName()."\n"
  51156. .str_repeat('-', Helper::strlen($command->getName()))."\n\n"
  51157. .'* Description: '.($command->getDescription() ?: '<none>')."\n"
  51158. .'* Usage:'."\n\n"
  51159. .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  51160. return $carry.' * `'.$usage.'`'."\n";
  51161. })
  51162. );
  51163. if ($help = $command->getProcessedHelp()) {
  51164. $this->write("\n");
  51165. $this->write($help);
  51166. }
  51167. if ($command->getNativeDefinition()) {
  51168. $this->write("\n\n");
  51169. $this->describeInputDefinition($command->getNativeDefinition());
  51170. }
  51171. }
  51172. protected function describeApplication(Application $application, array $options = array())
  51173. {
  51174. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  51175. $description = new ApplicationDescription($application, $describedNamespace);
  51176. $this->write($application->getName()."\n".str_repeat('=', Helper::strlen($application->getName())));
  51177. foreach ($description->getNamespaces() as $namespace) {
  51178. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  51179. $this->write("\n\n");
  51180. $this->write('**'.$namespace['id'].':**');
  51181. }
  51182. $this->write("\n\n");
  51183. $this->write(implode("\n", array_map(function ($commandName) {
  51184. return '* '.$commandName;
  51185. }, $namespace['commands'])));
  51186. }
  51187. foreach ($description->getCommands() as $command) {
  51188. $this->write("\n\n");
  51189. $this->write($this->describeCommand($command));
  51190. }
  51191. }
  51192. }
  51193. <?php
  51194. namespace Symfony\Component\Console\Descriptor;
  51195. use Symfony\Component\Console\Application;
  51196. use Symfony\Component\Console\Command\Command;
  51197. use Symfony\Component\Console\Formatter\OutputFormatter;
  51198. use Symfony\Component\Console\Helper\Helper;
  51199. use Symfony\Component\Console\Input\InputArgument;
  51200. use Symfony\Component\Console\Input\InputDefinition;
  51201. use Symfony\Component\Console\Input\InputOption;
  51202. class TextDescriptor extends Descriptor
  51203. {
  51204. protected function describeInputArgument(InputArgument $argument, array $options = array())
  51205. {
  51206. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  51207. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  51208. } else {
  51209. $default = '';
  51210. }
  51211. $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
  51212. $spacingWidth = $totalWidth - \strlen($argument->getName());
  51213. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  51214. $argument->getName(),
  51215. str_repeat(' ', $spacingWidth),
  51216. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  51217. $default
  51218. ), $options);
  51219. }
  51220. protected function describeInputOption(InputOption $option, array $options = array())
  51221. {
  51222. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  51223. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  51224. } else {
  51225. $default = '';
  51226. }
  51227. $value = '';
  51228. if ($option->acceptValue()) {
  51229. $value = '='.strtoupper($option->getName());
  51230. if ($option->isValueOptional()) {
  51231. $value = '['.$value.']';
  51232. }
  51233. }
  51234. $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
  51235. $synopsis = sprintf('%s%s',
  51236. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  51237. sprintf('--%s%s', $option->getName(), $value)
  51238. );
  51239. $spacingWidth = $totalWidth - Helper::strlen($synopsis);
  51240. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  51241. $synopsis,
  51242. str_repeat(' ', $spacingWidth),
  51243. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  51244. $default,
  51245. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  51246. ), $options);
  51247. }
  51248. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  51249. {
  51250. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  51251. foreach ($definition->getArguments() as $argument) {
  51252. $totalWidth = max($totalWidth, Helper::strlen($argument->getName()));
  51253. }
  51254. if ($definition->getArguments()) {
  51255. $this->writeText('<comment>Arguments:</comment>', $options);
  51256. $this->writeText("\n");
  51257. foreach ($definition->getArguments() as $argument) {
  51258. $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
  51259. $this->writeText("\n");
  51260. }
  51261. }
  51262. if ($definition->getArguments() && $definition->getOptions()) {
  51263. $this->writeText("\n");
  51264. }
  51265. if ($definition->getOptions()) {
  51266. $laterOptions = array();
  51267. $this->writeText('<comment>Options:</comment>', $options);
  51268. foreach ($definition->getOptions() as $option) {
  51269. if (\strlen($option->getShortcut()) > 1) {
  51270. $laterOptions[] = $option;
  51271. continue;
  51272. }
  51273. $this->writeText("\n");
  51274. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  51275. }
  51276. foreach ($laterOptions as $option) {
  51277. $this->writeText("\n");
  51278. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  51279. }
  51280. }
  51281. }
  51282. protected function describeCommand(Command $command, array $options = array())
  51283. {
  51284. $command->getSynopsis(true);
  51285. $command->getSynopsis(false);
  51286. $command->mergeApplicationDefinition(false);
  51287. $this->writeText('<comment>Usage:</comment>', $options);
  51288. foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
  51289. $this->writeText("\n");
  51290. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  51291. }
  51292. $this->writeText("\n");
  51293. $definition = $command->getNativeDefinition();
  51294. if ($definition->getOptions() || $definition->getArguments()) {
  51295. $this->writeText("\n");
  51296. $this->describeInputDefinition($definition, $options);
  51297. $this->writeText("\n");
  51298. }
  51299. if ($help = $command->getProcessedHelp()) {
  51300. $this->writeText("\n");
  51301. $this->writeText('<comment>Help:</comment>', $options);
  51302. $this->writeText("\n");
  51303. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  51304. $this->writeText("\n");
  51305. }
  51306. }
  51307. protected function describeApplication(Application $application, array $options = array())
  51308. {
  51309. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  51310. $description = new ApplicationDescription($application, $describedNamespace);
  51311. if (isset($options['raw_text']) && $options['raw_text']) {
  51312. $width = $this->getColumnWidth($description->getCommands());
  51313. foreach ($description->getCommands() as $command) {
  51314. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  51315. $this->writeText("\n");
  51316. }
  51317. } else {
  51318. if ('' != $help = $application->getHelp()) {
  51319. $this->writeText("$help\n\n", $options);
  51320. }
  51321. $this->writeText("<comment>Usage:</comment>\n", $options);
  51322. $this->writeText(" command [options] [arguments]\n\n", $options);
  51323. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  51324. $this->writeText("\n");
  51325. $this->writeText("\n");
  51326. $width = $this->getColumnWidth($description->getCommands());
  51327. if ($describedNamespace) {
  51328. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  51329. } else {
  51330. $this->writeText('<comment>Available commands:</comment>', $options);
  51331. }
  51332. foreach ($description->getNamespaces() as $namespace) {
  51333. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  51334. $this->writeText("\n");
  51335. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  51336. }
  51337. foreach ($namespace['commands'] as $name) {
  51338. $this->writeText("\n");
  51339. $spacingWidth = $width - Helper::strlen($name);
  51340. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
  51341. }
  51342. }
  51343. $this->writeText("\n");
  51344. }
  51345. }
  51346. private function writeText($content, array $options = array())
  51347. {
  51348. $this->write(
  51349. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  51350. isset($options['raw_output']) ? !$options['raw_output'] : true
  51351. );
  51352. }
  51353. private function formatDefaultValue($default)
  51354. {
  51355. if (INF === $default) {
  51356. return 'INF';
  51357. }
  51358. if (\is_string($default)) {
  51359. $default = OutputFormatter::escape($default);
  51360. } elseif (\is_array($default)) {
  51361. foreach ($default as $key => $value) {
  51362. if (\is_string($value)) {
  51363. $default[$key] = OutputFormatter::escape($value);
  51364. }
  51365. }
  51366. }
  51367. if (\PHP_VERSION_ID < 50400) {
  51368. return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
  51369. }
  51370. return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
  51371. }
  51372. private function getColumnWidth(array $commands)
  51373. {
  51374. $widths = array();
  51375. foreach ($commands as $command) {
  51376. $widths[] = Helper::strlen($command->getName());
  51377. foreach ($command->getAliases() as $alias) {
  51378. $widths[] = Helper::strlen($alias);
  51379. }
  51380. }
  51381. return max($widths) + 2;
  51382. }
  51383. private function calculateTotalWidthForOptions(array $options)
  51384. {
  51385. $totalWidth = 0;
  51386. foreach ($options as $option) {
  51387. $nameLength = 1 + max(\strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
  51388. if ($option->acceptValue()) {
  51389. $valueLength = 1 + Helper::strlen($option->getName());
  51390. $valueLength += $option->isValueOptional() ? 2 : 0;
  51391. $nameLength += $valueLength;
  51392. }
  51393. $totalWidth = max($totalWidth, $nameLength);
  51394. }
  51395. return $totalWidth;
  51396. }
  51397. }
  51398. <?php
  51399. namespace Symfony\Component\Console\Descriptor;
  51400. use Symfony\Component\Console\Application;
  51401. use Symfony\Component\Console\Command\Command;
  51402. use Symfony\Component\Console\Input\InputArgument;
  51403. use Symfony\Component\Console\Input\InputDefinition;
  51404. use Symfony\Component\Console\Input\InputOption;
  51405. class XmlDescriptor extends Descriptor
  51406. {
  51407. public function getInputDefinitionDocument(InputDefinition $definition)
  51408. {
  51409. $dom = new \DOMDocument('1.0', 'UTF-8');
  51410. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  51411. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  51412. foreach ($definition->getArguments() as $argument) {
  51413. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  51414. }
  51415. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  51416. foreach ($definition->getOptions() as $option) {
  51417. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  51418. }
  51419. return $dom;
  51420. }
  51421. public function getCommandDocument(Command $command)
  51422. {
  51423. $dom = new \DOMDocument('1.0', 'UTF-8');
  51424. $dom->appendChild($commandXML = $dom->createElement('command'));
  51425. $command->getSynopsis();
  51426. $command->mergeApplicationDefinition(false);
  51427. $commandXML->setAttribute('id', $command->getName());
  51428. $commandXML->setAttribute('name', $command->getName());
  51429. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  51430. foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
  51431. $usagesXML->appendChild($dom->createElement('usage', $usage));
  51432. }
  51433. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  51434. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  51435. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  51436. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  51437. $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
  51438. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  51439. return $dom;
  51440. }
  51441. public function getApplicationDocument(Application $application, $namespace = null)
  51442. {
  51443. $dom = new \DOMDocument('1.0', 'UTF-8');
  51444. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  51445. if ('UNKNOWN' !== $application->getName()) {
  51446. $rootXml->setAttribute('name', $application->getName());
  51447. if ('UNKNOWN' !== $application->getVersion()) {
  51448. $rootXml->setAttribute('version', $application->getVersion());
  51449. }
  51450. }
  51451. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  51452. $description = new ApplicationDescription($application, $namespace);
  51453. if ($namespace) {
  51454. $commandsXML->setAttribute('namespace', $namespace);
  51455. }
  51456. foreach ($description->getCommands() as $command) {
  51457. $this->appendDocument($commandsXML, $this->getCommandDocument($command));
  51458. }
  51459. if (!$namespace) {
  51460. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  51461. foreach ($description->getNamespaces() as $namespaceDescription) {
  51462. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  51463. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  51464. foreach ($namespaceDescription['commands'] as $name) {
  51465. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  51466. $commandXML->appendChild($dom->createTextNode($name));
  51467. }
  51468. }
  51469. }
  51470. return $dom;
  51471. }
  51472. protected function describeInputArgument(InputArgument $argument, array $options = array())
  51473. {
  51474. $this->writeDocument($this->getInputArgumentDocument($argument));
  51475. }
  51476. protected function describeInputOption(InputOption $option, array $options = array())
  51477. {
  51478. $this->writeDocument($this->getInputOptionDocument($option));
  51479. }
  51480. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  51481. {
  51482. $this->writeDocument($this->getInputDefinitionDocument($definition));
  51483. }
  51484. protected function describeCommand(Command $command, array $options = array())
  51485. {
  51486. $this->writeDocument($this->getCommandDocument($command));
  51487. }
  51488. protected function describeApplication(Application $application, array $options = array())
  51489. {
  51490. $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
  51491. }
  51492. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  51493. {
  51494. foreach ($importedParent->childNodes as $childNode) {
  51495. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  51496. }
  51497. }
  51498. private function writeDocument(\DOMDocument $dom)
  51499. {
  51500. $dom->formatOutput = true;
  51501. $this->write($dom->saveXML());
  51502. }
  51503. private function getInputArgumentDocument(InputArgument $argument)
  51504. {
  51505. $dom = new \DOMDocument('1.0', 'UTF-8');
  51506. $dom->appendChild($objectXML = $dom->createElement('argument'));
  51507. $objectXML->setAttribute('name', $argument->getName());
  51508. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  51509. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  51510. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  51511. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  51512. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  51513. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
  51514. foreach ($defaults as $default) {
  51515. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  51516. $defaultXML->appendChild($dom->createTextNode($default));
  51517. }
  51518. return $dom;
  51519. }
  51520. private function getInputOptionDocument(InputOption $option)
  51521. {
  51522. $dom = new \DOMDocument('1.0', 'UTF-8');
  51523. $dom->appendChild($objectXML = $dom->createElement('option'));
  51524. $objectXML->setAttribute('name', '--'.$option->getName());
  51525. $pos = strpos($option->getShortcut(), '|');
  51526. if (false !== $pos) {
  51527. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  51528. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  51529. } else {
  51530. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  51531. }
  51532. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  51533. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  51534. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  51535. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  51536. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  51537. if ($option->acceptValue()) {
  51538. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
  51539. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  51540. if (!empty($defaults)) {
  51541. foreach ($defaults as $default) {
  51542. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  51543. $defaultXML->appendChild($dom->createTextNode($default));
  51544. }
  51545. }
  51546. }
  51547. return $dom;
  51548. }
  51549. }
  51550. <?php
  51551. namespace Symfony\Component\Console\Event;
  51552. class ConsoleCommandEvent extends ConsoleEvent
  51553. {
  51554. const RETURN_CODE_DISABLED = 113;
  51555. private $commandShouldRun = true;
  51556. public function disableCommand()
  51557. {
  51558. return $this->commandShouldRun = false;
  51559. }
  51560. public function enableCommand()
  51561. {
  51562. return $this->commandShouldRun = true;
  51563. }
  51564. public function commandShouldRun()
  51565. {
  51566. return $this->commandShouldRun;
  51567. }
  51568. }
  51569. <?php
  51570. namespace Symfony\Component\Console\Event;
  51571. use Symfony\Component\Console\Command\Command;
  51572. use Symfony\Component\Console\Input\InputInterface;
  51573. use Symfony\Component\Console\Output\OutputInterface;
  51574. use Symfony\Component\EventDispatcher\Event;
  51575. class ConsoleEvent extends Event
  51576. {
  51577. protected $command;
  51578. private $input;
  51579. private $output;
  51580. public function __construct(Command $command, InputInterface $input, OutputInterface $output)
  51581. {
  51582. $this->command = $command;
  51583. $this->input = $input;
  51584. $this->output = $output;
  51585. }
  51586. public function getCommand()
  51587. {
  51588. return $this->command;
  51589. }
  51590. public function getInput()
  51591. {
  51592. return $this->input;
  51593. }
  51594. public function getOutput()
  51595. {
  51596. return $this->output;
  51597. }
  51598. }
  51599. <?php
  51600. namespace Symfony\Component\Console\Event;
  51601. use Symfony\Component\Console\Command\Command;
  51602. use Symfony\Component\Console\Input\InputInterface;
  51603. use Symfony\Component\Console\Output\OutputInterface;
  51604. class ConsoleExceptionEvent extends ConsoleEvent
  51605. {
  51606. private $exception;
  51607. private $exitCode;
  51608. public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
  51609. {
  51610. parent::__construct($command, $input, $output);
  51611. $this->setException($exception);
  51612. $this->exitCode = (int) $exitCode;
  51613. }
  51614. public function getException()
  51615. {
  51616. return $this->exception;
  51617. }
  51618. public function setException(\Exception $exception)
  51619. {
  51620. $this->exception = $exception;
  51621. }
  51622. public function getExitCode()
  51623. {
  51624. return $this->exitCode;
  51625. }
  51626. }
  51627. <?php
  51628. namespace Symfony\Component\Console\Event;
  51629. use Symfony\Component\Console\Command\Command;
  51630. use Symfony\Component\Console\Input\InputInterface;
  51631. use Symfony\Component\Console\Output\OutputInterface;
  51632. class ConsoleTerminateEvent extends ConsoleEvent
  51633. {
  51634. private $exitCode;
  51635. public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
  51636. {
  51637. parent::__construct($command, $input, $output);
  51638. $this->setExitCode($exitCode);
  51639. }
  51640. public function setExitCode($exitCode)
  51641. {
  51642. $this->exitCode = (int) $exitCode;
  51643. }
  51644. public function getExitCode()
  51645. {
  51646. return $this->exitCode;
  51647. }
  51648. }
  51649. <?php
  51650. namespace Symfony\Component\Console\Exception;
  51651. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  51652. {
  51653. private $alternatives;
  51654. public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null)
  51655. {
  51656. parent::__construct($message, $code, $previous);
  51657. $this->alternatives = $alternatives;
  51658. }
  51659. public function getAlternatives()
  51660. {
  51661. return $this->alternatives;
  51662. }
  51663. }
  51664. <?php
  51665. namespace Symfony\Component\Console\Exception;
  51666. interface ExceptionInterface
  51667. {
  51668. }
  51669. <?php
  51670. namespace Symfony\Component\Console\Exception;
  51671. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  51672. {
  51673. }
  51674. <?php
  51675. namespace Symfony\Component\Console\Exception;
  51676. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  51677. {
  51678. }
  51679. <?php
  51680. namespace Symfony\Component\Console\Exception;
  51681. class LogicException extends \LogicException implements ExceptionInterface
  51682. {
  51683. }
  51684. <?php
  51685. namespace Symfony\Component\Console\Exception;
  51686. class RuntimeException extends \RuntimeException implements ExceptionInterface
  51687. {
  51688. }
  51689. <?php
  51690. namespace Symfony\Component\Console\Formatter;
  51691. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51692. class OutputFormatter implements OutputFormatterInterface
  51693. {
  51694. private $decorated;
  51695. private $styles = array();
  51696. private $styleStack;
  51697. public static function escape($text)
  51698. {
  51699. $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
  51700. return self::escapeTrailingBackslash($text);
  51701. }
  51702. public static function escapeTrailingBackslash($text)
  51703. {
  51704. if ('\\' === substr($text, -1)) {
  51705. $len = \strlen($text);
  51706. $text = rtrim($text, '\\');
  51707. $text = str_replace("\0", '', $text);
  51708. $text .= str_repeat("\0", $len - \strlen($text));
  51709. }
  51710. return $text;
  51711. }
  51712. public function __construct($decorated = false, array $styles = array())
  51713. {
  51714. $this->decorated = (bool) $decorated;
  51715. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  51716. $this->setStyle('info', new OutputFormatterStyle('green'));
  51717. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  51718. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  51719. foreach ($styles as $name => $style) {
  51720. $this->setStyle($name, $style);
  51721. }
  51722. $this->styleStack = new OutputFormatterStyleStack();
  51723. }
  51724. public function setDecorated($decorated)
  51725. {
  51726. $this->decorated = (bool) $decorated;
  51727. }
  51728. public function isDecorated()
  51729. {
  51730. return $this->decorated;
  51731. }
  51732. public function setStyle($name, OutputFormatterStyleInterface $style)
  51733. {
  51734. $this->styles[strtolower($name)] = $style;
  51735. }
  51736. public function hasStyle($name)
  51737. {
  51738. return isset($this->styles[strtolower($name)]);
  51739. }
  51740. public function getStyle($name)
  51741. {
  51742. if (!$this->hasStyle($name)) {
  51743. throw new InvalidArgumentException(sprintf('Undefined style: %s', $name));
  51744. }
  51745. return $this->styles[strtolower($name)];
  51746. }
  51747. public function format($message)
  51748. {
  51749. $message = (string) $message;
  51750. $offset = 0;
  51751. $output = '';
  51752. $tagRegex = '[a-z][a-z0-9_=;-]*+';
  51753. preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
  51754. foreach ($matches[0] as $i => $match) {
  51755. $pos = $match[1];
  51756. $text = $match[0];
  51757. if (0 != $pos && '\\' == $message[$pos - 1]) {
  51758. continue;
  51759. }
  51760. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
  51761. $offset = $pos + \strlen($text);
  51762. if ($open = '/' != $text[1]) {
  51763. $tag = $matches[1][$i][0];
  51764. } else {
  51765. $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
  51766. }
  51767. if (!$open && !$tag) {
  51768. $this->styleStack->pop();
  51769. } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
  51770. $output .= $this->applyCurrentStyle($text);
  51771. } elseif ($open) {
  51772. $this->styleStack->push($style);
  51773. } else {
  51774. $this->styleStack->pop($style);
  51775. }
  51776. }
  51777. $output .= $this->applyCurrentStyle(substr($message, $offset));
  51778. if (false !== strpos($output, "\0")) {
  51779. return strtr($output, array("\0" => '\\', '\\<' => '<'));
  51780. }
  51781. return str_replace('\\<', '<', $output);
  51782. }
  51783. public function getStyleStack()
  51784. {
  51785. return $this->styleStack;
  51786. }
  51787. private function createStyleFromString($string)
  51788. {
  51789. if (isset($this->styles[$string])) {
  51790. return $this->styles[$string];
  51791. }
  51792. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
  51793. return false;
  51794. }
  51795. $style = new OutputFormatterStyle();
  51796. foreach ($matches as $match) {
  51797. array_shift($match);
  51798. if ('fg' == $match[0]) {
  51799. $style->setForeground($match[1]);
  51800. } elseif ('bg' == $match[0]) {
  51801. $style->setBackground($match[1]);
  51802. } else {
  51803. try {
  51804. $style->setOption($match[1]);
  51805. } catch (\InvalidArgumentException $e) {
  51806. return false;
  51807. }
  51808. }
  51809. }
  51810. return $style;
  51811. }
  51812. private function applyCurrentStyle($text)
  51813. {
  51814. return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
  51815. }
  51816. }
  51817. <?php
  51818. namespace Symfony\Component\Console\Formatter;
  51819. interface OutputFormatterInterface
  51820. {
  51821. public function setDecorated($decorated);
  51822. public function isDecorated();
  51823. public function setStyle($name, OutputFormatterStyleInterface $style);
  51824. public function hasStyle($name);
  51825. public function getStyle($name);
  51826. public function format($message);
  51827. }
  51828. <?php
  51829. namespace Symfony\Component\Console\Formatter;
  51830. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51831. class OutputFormatterStyle implements OutputFormatterStyleInterface
  51832. {
  51833. private static $availableForegroundColors = array(
  51834. 'black' => array('set' => 30, 'unset' => 39),
  51835. 'red' => array('set' => 31, 'unset' => 39),
  51836. 'green' => array('set' => 32, 'unset' => 39),
  51837. 'yellow' => array('set' => 33, 'unset' => 39),
  51838. 'blue' => array('set' => 34, 'unset' => 39),
  51839. 'magenta' => array('set' => 35, 'unset' => 39),
  51840. 'cyan' => array('set' => 36, 'unset' => 39),
  51841. 'white' => array('set' => 37, 'unset' => 39),
  51842. 'default' => array('set' => 39, 'unset' => 39),
  51843. );
  51844. private static $availableBackgroundColors = array(
  51845. 'black' => array('set' => 40, 'unset' => 49),
  51846. 'red' => array('set' => 41, 'unset' => 49),
  51847. 'green' => array('set' => 42, 'unset' => 49),
  51848. 'yellow' => array('set' => 43, 'unset' => 49),
  51849. 'blue' => array('set' => 44, 'unset' => 49),
  51850. 'magenta' => array('set' => 45, 'unset' => 49),
  51851. 'cyan' => array('set' => 46, 'unset' => 49),
  51852. 'white' => array('set' => 47, 'unset' => 49),
  51853. 'default' => array('set' => 49, 'unset' => 49),
  51854. );
  51855. private static $availableOptions = array(
  51856. 'bold' => array('set' => 1, 'unset' => 22),
  51857. 'underscore' => array('set' => 4, 'unset' => 24),
  51858. 'blink' => array('set' => 5, 'unset' => 25),
  51859. 'reverse' => array('set' => 7, 'unset' => 27),
  51860. 'conceal' => array('set' => 8, 'unset' => 28),
  51861. );
  51862. private $foreground;
  51863. private $background;
  51864. private $options = array();
  51865. public function __construct($foreground = null, $background = null, array $options = array())
  51866. {
  51867. if (null !== $foreground) {
  51868. $this->setForeground($foreground);
  51869. }
  51870. if (null !== $background) {
  51871. $this->setBackground($background);
  51872. }
  51873. if (\count($options)) {
  51874. $this->setOptions($options);
  51875. }
  51876. }
  51877. public function setForeground($color = null)
  51878. {
  51879. if (null === $color) {
  51880. $this->foreground = null;
  51881. return;
  51882. }
  51883. if (!isset(static::$availableForegroundColors[$color])) {
  51884. throw new InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors))));
  51885. }
  51886. $this->foreground = static::$availableForegroundColors[$color];
  51887. }
  51888. public function setBackground($color = null)
  51889. {
  51890. if (null === $color) {
  51891. $this->background = null;
  51892. return;
  51893. }
  51894. if (!isset(static::$availableBackgroundColors[$color])) {
  51895. throw new InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors))));
  51896. }
  51897. $this->background = static::$availableBackgroundColors[$color];
  51898. }
  51899. public function setOption($option)
  51900. {
  51901. if (!isset(static::$availableOptions[$option])) {
  51902. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  51903. }
  51904. if (!\in_array(static::$availableOptions[$option], $this->options)) {
  51905. $this->options[] = static::$availableOptions[$option];
  51906. }
  51907. }
  51908. public function unsetOption($option)
  51909. {
  51910. if (!isset(static::$availableOptions[$option])) {
  51911. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  51912. }
  51913. $pos = array_search(static::$availableOptions[$option], $this->options);
  51914. if (false !== $pos) {
  51915. unset($this->options[$pos]);
  51916. }
  51917. }
  51918. public function setOptions(array $options)
  51919. {
  51920. $this->options = array();
  51921. foreach ($options as $option) {
  51922. $this->setOption($option);
  51923. }
  51924. }
  51925. public function apply($text)
  51926. {
  51927. $setCodes = array();
  51928. $unsetCodes = array();
  51929. if (null !== $this->foreground) {
  51930. $setCodes[] = $this->foreground['set'];
  51931. $unsetCodes[] = $this->foreground['unset'];
  51932. }
  51933. if (null !== $this->background) {
  51934. $setCodes[] = $this->background['set'];
  51935. $unsetCodes[] = $this->background['unset'];
  51936. }
  51937. if (\count($this->options)) {
  51938. foreach ($this->options as $option) {
  51939. $setCodes[] = $option['set'];
  51940. $unsetCodes[] = $option['unset'];
  51941. }
  51942. }
  51943. if (0 === \count($setCodes)) {
  51944. return $text;
  51945. }
  51946. return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
  51947. }
  51948. }
  51949. <?php
  51950. namespace Symfony\Component\Console\Formatter;
  51951. interface OutputFormatterStyleInterface
  51952. {
  51953. public function setForeground($color = null);
  51954. public function setBackground($color = null);
  51955. public function setOption($option);
  51956. public function unsetOption($option);
  51957. public function setOptions(array $options);
  51958. public function apply($text);
  51959. }
  51960. <?php
  51961. namespace Symfony\Component\Console\Formatter;
  51962. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51963. class OutputFormatterStyleStack
  51964. {
  51965. private $styles;
  51966. private $emptyStyle;
  51967. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  51968. {
  51969. $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
  51970. $this->reset();
  51971. }
  51972. public function reset()
  51973. {
  51974. $this->styles = array();
  51975. }
  51976. public function push(OutputFormatterStyleInterface $style)
  51977. {
  51978. $this->styles[] = $style;
  51979. }
  51980. public function pop(OutputFormatterStyleInterface $style = null)
  51981. {
  51982. if (empty($this->styles)) {
  51983. return $this->emptyStyle;
  51984. }
  51985. if (null === $style) {
  51986. return array_pop($this->styles);
  51987. }
  51988. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  51989. if ($style->apply('') === $stackedStyle->apply('')) {
  51990. $this->styles = \array_slice($this->styles, 0, $index);
  51991. return $stackedStyle;
  51992. }
  51993. }
  51994. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  51995. }
  51996. public function getCurrent()
  51997. {
  51998. if (empty($this->styles)) {
  51999. return $this->emptyStyle;
  52000. }
  52001. return $this->styles[\count($this->styles) - 1];
  52002. }
  52003. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  52004. {
  52005. $this->emptyStyle = $emptyStyle;
  52006. return $this;
  52007. }
  52008. public function getEmptyStyle()
  52009. {
  52010. return $this->emptyStyle;
  52011. }
  52012. }
  52013. <?php
  52014. namespace Symfony\Component\Console\Helper;
  52015. class DebugFormatterHelper extends Helper
  52016. {
  52017. private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
  52018. private $started = array();
  52019. private $count = -1;
  52020. public function start($id, $message, $prefix = 'RUN')
  52021. {
  52022. $this->started[$id] = array('border' => ++$this->count % \count($this->colors));
  52023. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  52024. }
  52025. public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR')
  52026. {
  52027. $message = '';
  52028. if ($error) {
  52029. if (isset($this->started[$id]['out'])) {
  52030. $message .= "\n";
  52031. unset($this->started[$id]['out']);
  52032. }
  52033. if (!isset($this->started[$id]['err'])) {
  52034. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  52035. $this->started[$id]['err'] = true;
  52036. }
  52037. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  52038. } else {
  52039. if (isset($this->started[$id]['err'])) {
  52040. $message .= "\n";
  52041. unset($this->started[$id]['err']);
  52042. }
  52043. if (!isset($this->started[$id]['out'])) {
  52044. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  52045. $this->started[$id]['out'] = true;
  52046. }
  52047. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  52048. }
  52049. return $message;
  52050. }
  52051. public function stop($id, $message, $successful, $prefix = 'RES')
  52052. {
  52053. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  52054. if ($successful) {
  52055. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  52056. }
  52057. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  52058. unset($this->started[$id]['out'], $this->started[$id]['err']);
  52059. return $message;
  52060. }
  52061. private function getBorder($id)
  52062. {
  52063. return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
  52064. }
  52065. public function getName()
  52066. {
  52067. return 'debug_formatter';
  52068. }
  52069. }
  52070. <?php
  52071. namespace Symfony\Component\Console\Helper;
  52072. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  52073. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  52074. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  52075. use Symfony\Component\Console\Descriptor\TextDescriptor;
  52076. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  52077. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52078. use Symfony\Component\Console\Output\OutputInterface;
  52079. class DescriptorHelper extends Helper
  52080. {
  52081. private $descriptors = array();
  52082. public function __construct()
  52083. {
  52084. $this
  52085. ->register('txt', new TextDescriptor())
  52086. ->register('xml', new XmlDescriptor())
  52087. ->register('json', new JsonDescriptor())
  52088. ->register('md', new MarkdownDescriptor())
  52089. ;
  52090. }
  52091. public function describe(OutputInterface $output, $object, array $options = array())
  52092. {
  52093. $options = array_merge(array(
  52094. 'raw_text' => false,
  52095. 'format' => 'txt',
  52096. ), $options);
  52097. if (!isset($this->descriptors[$options['format']])) {
  52098. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  52099. }
  52100. $descriptor = $this->descriptors[$options['format']];
  52101. $descriptor->describe($output, $object, $options);
  52102. }
  52103. public function register($format, DescriptorInterface $descriptor)
  52104. {
  52105. $this->descriptors[$format] = $descriptor;
  52106. return $this;
  52107. }
  52108. public function getName()
  52109. {
  52110. return 'descriptor';
  52111. }
  52112. }
  52113. <?php
  52114. namespace Symfony\Component\Console\Helper;
  52115. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52116. use Symfony\Component\Console\Exception\RuntimeException;
  52117. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  52118. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  52119. use Symfony\Component\Console\Output\OutputInterface;
  52120. class DialogHelper extends InputAwareHelper
  52121. {
  52122. private $inputStream;
  52123. private static $shell;
  52124. private static $stty;
  52125. public function __construct($triggerDeprecationError = true)
  52126. {
  52127. if ($triggerDeprecationError) {
  52128. @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);
  52129. }
  52130. }
  52131. public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  52132. {
  52133. if ($output instanceof ConsoleOutputInterface) {
  52134. $output = $output->getErrorOutput();
  52135. }
  52136. $width = max(array_map('strlen', array_keys($choices)));
  52137. $messages = (array) $question;
  52138. foreach ($choices as $key => $value) {
  52139. $messages[] = sprintf(" [<info>%-{$width}s</info>] %s", $key, $value);
  52140. }
  52141. $output->writeln($messages);
  52142. $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
  52143. $selectedChoices = str_replace(' ', '', $picked);
  52144. if ($multiselect) {
  52145. if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
  52146. throw new InvalidArgumentException(sprintf($errorMessage, $picked));
  52147. }
  52148. $selectedChoices = explode(',', $selectedChoices);
  52149. } else {
  52150. $selectedChoices = array($picked);
  52151. }
  52152. $multiselectChoices = array();
  52153. foreach ($selectedChoices as $value) {
  52154. if (empty($choices[$value])) {
  52155. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  52156. }
  52157. $multiselectChoices[] = $value;
  52158. }
  52159. if ($multiselect) {
  52160. return $multiselectChoices;
  52161. }
  52162. return $picked;
  52163. }, $attempts, $default);
  52164. return $result;
  52165. }
  52166. public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
  52167. {
  52168. if ($this->input && !$this->input->isInteractive()) {
  52169. return $default;
  52170. }
  52171. if ($output instanceof ConsoleOutputInterface) {
  52172. $output = $output->getErrorOutput();
  52173. }
  52174. $output->write($question);
  52175. $inputStream = $this->inputStream ?: STDIN;
  52176. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  52177. $ret = fgets($inputStream, 4096);
  52178. if (false === $ret) {
  52179. throw new RuntimeException('Aborted');
  52180. }
  52181. $ret = trim($ret);
  52182. } else {
  52183. $ret = '';
  52184. $i = 0;
  52185. $ofs = -1;
  52186. $matches = $autocomplete;
  52187. $numMatches = \count($matches);
  52188. $sttyMode = shell_exec('stty -g');
  52189. shell_exec('stty -icanon -echo');
  52190. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  52191. while (!feof($inputStream)) {
  52192. $c = fread($inputStream, 1);
  52193. if ("\177" === $c) {
  52194. if (0 === $numMatches && 0 !== $i) {
  52195. --$i;
  52196. $output->write("\033[1D");
  52197. }
  52198. if (0 === $i) {
  52199. $ofs = -1;
  52200. $matches = $autocomplete;
  52201. $numMatches = \count($matches);
  52202. } else {
  52203. $numMatches = 0;
  52204. }
  52205. $ret = substr($ret, 0, $i);
  52206. } elseif ("\033" === $c) {
  52207. $c .= fread($inputStream, 2);
  52208. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  52209. if ('A' === $c[2] && -1 === $ofs) {
  52210. $ofs = 0;
  52211. }
  52212. if (0 === $numMatches) {
  52213. continue;
  52214. }
  52215. $ofs += ('A' === $c[2]) ? -1 : 1;
  52216. $ofs = ($numMatches + $ofs) % $numMatches;
  52217. }
  52218. } elseif (\ord($c) < 32) {
  52219. if ("\t" === $c || "\n" === $c) {
  52220. if ($numMatches > 0 && -1 !== $ofs) {
  52221. $ret = $matches[$ofs];
  52222. $output->write(substr($ret, $i));
  52223. $i = \strlen($ret);
  52224. }
  52225. if ("\n" === $c) {
  52226. $output->write($c);
  52227. break;
  52228. }
  52229. $numMatches = 0;
  52230. }
  52231. continue;
  52232. } else {
  52233. $output->write($c);
  52234. $ret .= $c;
  52235. ++$i;
  52236. $numMatches = 0;
  52237. $ofs = 0;
  52238. foreach ($autocomplete as $value) {
  52239. if (0 === strpos($value, $ret) && $i !== \strlen($value)) {
  52240. $matches[$numMatches++] = $value;
  52241. }
  52242. }
  52243. }
  52244. $output->write("\033[K");
  52245. if ($numMatches > 0 && -1 !== $ofs) {
  52246. $output->write("\0337");
  52247. $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
  52248. $output->write("\0338");
  52249. }
  52250. }
  52251. shell_exec(sprintf('stty %s', $sttyMode));
  52252. }
  52253. return \strlen($ret) > 0 ? $ret : $default;
  52254. }
  52255. public function askConfirmation(OutputInterface $output, $question, $default = true)
  52256. {
  52257. $answer = 'z';
  52258. while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) {
  52259. $answer = $this->ask($output, $question);
  52260. }
  52261. if (false === $default) {
  52262. return $answer && 'y' == strtolower($answer[0]);
  52263. }
  52264. return !$answer || 'y' == strtolower($answer[0]);
  52265. }
  52266. public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
  52267. {
  52268. if ($output instanceof ConsoleOutputInterface) {
  52269. $output = $output->getErrorOutput();
  52270. }
  52271. if ('\\' === \DIRECTORY_SEPARATOR) {
  52272. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  52273. if ('phar:' === substr(__FILE__, 0, 5)) {
  52274. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  52275. copy($exe, $tmpExe);
  52276. $exe = $tmpExe;
  52277. }
  52278. $output->write($question);
  52279. $value = rtrim(shell_exec($exe));
  52280. $output->writeln('');
  52281. if (isset($tmpExe)) {
  52282. unlink($tmpExe);
  52283. }
  52284. return $value;
  52285. }
  52286. if ($this->hasSttyAvailable()) {
  52287. $output->write($question);
  52288. $sttyMode = shell_exec('stty -g');
  52289. shell_exec('stty -echo');
  52290. $value = fgets($this->inputStream ?: STDIN, 4096);
  52291. shell_exec(sprintf('stty %s', $sttyMode));
  52292. if (false === $value) {
  52293. throw new RuntimeException('Aborted');
  52294. }
  52295. $value = trim($value);
  52296. $output->writeln('');
  52297. return $value;
  52298. }
  52299. if (false !== $shell = $this->getShell()) {
  52300. $output->write($question);
  52301. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  52302. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  52303. $value = rtrim(shell_exec($command));
  52304. $output->writeln('');
  52305. return $value;
  52306. }
  52307. if ($fallback) {
  52308. return $this->ask($output, $question);
  52309. }
  52310. throw new RuntimeException('Unable to hide the response');
  52311. }
  52312. public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
  52313. {
  52314. $that = $this;
  52315. $interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
  52316. return $that->ask($output, $question, $default, $autocomplete);
  52317. };
  52318. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  52319. }
  52320. public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
  52321. {
  52322. $that = $this;
  52323. $interviewer = function () use ($output, $question, $fallback, $that) {
  52324. return $that->askHiddenResponse($output, $question, $fallback);
  52325. };
  52326. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  52327. }
  52328. public function setInputStream($stream)
  52329. {
  52330. $this->inputStream = $stream;
  52331. }
  52332. public function getInputStream()
  52333. {
  52334. return $this->inputStream;
  52335. }
  52336. public function getName()
  52337. {
  52338. return 'dialog';
  52339. }
  52340. private function getShell()
  52341. {
  52342. if (null !== self::$shell) {
  52343. return self::$shell;
  52344. }
  52345. self::$shell = false;
  52346. if (file_exists('/usr/bin/env')) {
  52347. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  52348. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  52349. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  52350. self::$shell = $sh;
  52351. break;
  52352. }
  52353. }
  52354. }
  52355. return self::$shell;
  52356. }
  52357. private function hasSttyAvailable()
  52358. {
  52359. if (null !== self::$stty) {
  52360. return self::$stty;
  52361. }
  52362. exec('stty 2>&1', $output, $exitcode);
  52363. return self::$stty = 0 === $exitcode;
  52364. }
  52365. private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
  52366. {
  52367. if ($output instanceof ConsoleOutputInterface) {
  52368. $output = $output->getErrorOutput();
  52369. }
  52370. $e = null;
  52371. while (false === $attempts || $attempts--) {
  52372. if (null !== $e) {
  52373. $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
  52374. }
  52375. try {
  52376. return \call_user_func($validator, $interviewer());
  52377. } catch (\Exception $e) {
  52378. }
  52379. }
  52380. throw $e;
  52381. }
  52382. }
  52383. <?php
  52384. namespace Symfony\Component\Console\Helper;
  52385. use Symfony\Component\Console\Formatter\OutputFormatter;
  52386. class FormatterHelper extends Helper
  52387. {
  52388. public function formatSection($section, $message, $style = 'info')
  52389. {
  52390. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  52391. }
  52392. public function formatBlock($messages, $style, $large = false)
  52393. {
  52394. if (!\is_array($messages)) {
  52395. $messages = array($messages);
  52396. }
  52397. $len = 0;
  52398. $lines = array();
  52399. foreach ($messages as $message) {
  52400. $message = OutputFormatter::escape($message);
  52401. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  52402. $len = max($this->strlen($message) + ($large ? 4 : 2), $len);
  52403. }
  52404. $messages = $large ? array(str_repeat(' ', $len)) : array();
  52405. for ($i = 0; isset($lines[$i]); ++$i) {
  52406. $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
  52407. }
  52408. if ($large) {
  52409. $messages[] = str_repeat(' ', $len);
  52410. }
  52411. for ($i = 0; isset($messages[$i]); ++$i) {
  52412. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  52413. }
  52414. return implode("\n", $messages);
  52415. }
  52416. public function getName()
  52417. {
  52418. return 'formatter';
  52419. }
  52420. }
  52421. <?php
  52422. namespace Symfony\Component\Console\Helper;
  52423. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  52424. abstract class Helper implements HelperInterface
  52425. {
  52426. protected $helperSet = null;
  52427. public function setHelperSet(HelperSet $helperSet = null)
  52428. {
  52429. $this->helperSet = $helperSet;
  52430. }
  52431. public function getHelperSet()
  52432. {
  52433. return $this->helperSet;
  52434. }
  52435. public static function strlen($string)
  52436. {
  52437. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  52438. return \strlen($string);
  52439. }
  52440. return mb_strwidth($string, $encoding);
  52441. }
  52442. public static function formatTime($secs)
  52443. {
  52444. static $timeFormats = array(
  52445. array(0, '< 1 sec'),
  52446. array(1, '1 sec'),
  52447. array(2, 'secs', 1),
  52448. array(60, '1 min'),
  52449. array(120, 'mins', 60),
  52450. array(3600, '1 hr'),
  52451. array(7200, 'hrs', 3600),
  52452. array(86400, '1 day'),
  52453. array(172800, 'days', 86400),
  52454. );
  52455. foreach ($timeFormats as $index => $format) {
  52456. if ($secs >= $format[0]) {
  52457. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  52458. || $index == \count($timeFormats) - 1
  52459. ) {
  52460. if (2 == \count($format)) {
  52461. return $format[1];
  52462. }
  52463. return floor($secs / $format[2]).' '.$format[1];
  52464. }
  52465. }
  52466. }
  52467. }
  52468. public static function formatMemory($memory)
  52469. {
  52470. if ($memory >= 1024 * 1024 * 1024) {
  52471. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  52472. }
  52473. if ($memory >= 1024 * 1024) {
  52474. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  52475. }
  52476. if ($memory >= 1024) {
  52477. return sprintf('%d KiB', $memory / 1024);
  52478. }
  52479. return sprintf('%d B', $memory);
  52480. }
  52481. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
  52482. {
  52483. return self::strlen(self::removeDecoration($formatter, $string));
  52484. }
  52485. public static function removeDecoration(OutputFormatterInterface $formatter, $string)
  52486. {
  52487. $isDecorated = $formatter->isDecorated();
  52488. $formatter->setDecorated(false);
  52489. $string = $formatter->format($string);
  52490. $string = preg_replace("/\033\[[^m]*m/", '', $string);
  52491. $formatter->setDecorated($isDecorated);
  52492. return $string;
  52493. }
  52494. }
  52495. <?php
  52496. namespace Symfony\Component\Console\Helper;
  52497. interface HelperInterface
  52498. {
  52499. public function setHelperSet(HelperSet $helperSet = null);
  52500. public function getHelperSet();
  52501. public function getName();
  52502. }
  52503. <?php
  52504. namespace Symfony\Component\Console\Helper;
  52505. use Symfony\Component\Console\Command\Command;
  52506. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52507. class HelperSet implements \IteratorAggregate
  52508. {
  52509. private $helpers = array();
  52510. private $command;
  52511. public function __construct(array $helpers = array())
  52512. {
  52513. foreach ($helpers as $alias => $helper) {
  52514. $this->set($helper, \is_int($alias) ? null : $alias);
  52515. }
  52516. }
  52517. public function set(HelperInterface $helper, $alias = null)
  52518. {
  52519. $this->helpers[$helper->getName()] = $helper;
  52520. if (null !== $alias) {
  52521. $this->helpers[$alias] = $helper;
  52522. }
  52523. $helper->setHelperSet($this);
  52524. }
  52525. public function has($name)
  52526. {
  52527. return isset($this->helpers[$name]);
  52528. }
  52529. public function get($name)
  52530. {
  52531. if (!$this->has($name)) {
  52532. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  52533. }
  52534. if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
  52535. @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);
  52536. } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
  52537. @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);
  52538. } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
  52539. @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);
  52540. }
  52541. return $this->helpers[$name];
  52542. }
  52543. public function setCommand(Command $command = null)
  52544. {
  52545. $this->command = $command;
  52546. }
  52547. public function getCommand()
  52548. {
  52549. return $this->command;
  52550. }
  52551. public function getIterator()
  52552. {
  52553. return new \ArrayIterator($this->helpers);
  52554. }
  52555. }
  52556. <?php
  52557. namespace Symfony\Component\Console\Helper;
  52558. use Symfony\Component\Console\Input\InputAwareInterface;
  52559. use Symfony\Component\Console\Input\InputInterface;
  52560. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  52561. {
  52562. protected $input;
  52563. public function setInput(InputInterface $input)
  52564. {
  52565. $this->input = $input;
  52566. }
  52567. }
  52568. <?php
  52569. namespace Symfony\Component\Console\Helper;
  52570. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  52571. use Symfony\Component\Console\Output\OutputInterface;
  52572. use Symfony\Component\Process\Exception\ProcessFailedException;
  52573. use Symfony\Component\Process\Process;
  52574. use Symfony\Component\Process\ProcessBuilder;
  52575. class ProcessHelper extends Helper
  52576. {
  52577. public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
  52578. {
  52579. if ($output instanceof ConsoleOutputInterface) {
  52580. $output = $output->getErrorOutput();
  52581. }
  52582. $formatter = $this->getHelperSet()->get('debug_formatter');
  52583. if (\is_array($cmd)) {
  52584. $process = ProcessBuilder::create($cmd)->getProcess();
  52585. } elseif ($cmd instanceof Process) {
  52586. $process = $cmd;
  52587. } else {
  52588. $process = new Process($cmd);
  52589. }
  52590. if ($verbosity <= $output->getVerbosity()) {
  52591. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  52592. }
  52593. if ($output->isDebug()) {
  52594. $callback = $this->wrapCallback($output, $process, $callback);
  52595. }
  52596. $process->run($callback);
  52597. if ($verbosity <= $output->getVerbosity()) {
  52598. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  52599. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  52600. }
  52601. if (!$process->isSuccessful() && null !== $error) {
  52602. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  52603. }
  52604. return $process;
  52605. }
  52606. public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null)
  52607. {
  52608. $process = $this->run($output, $cmd, $error, $callback);
  52609. if (!$process->isSuccessful()) {
  52610. throw new ProcessFailedException($process);
  52611. }
  52612. return $process;
  52613. }
  52614. public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
  52615. {
  52616. if ($output instanceof ConsoleOutputInterface) {
  52617. $output = $output->getErrorOutput();
  52618. }
  52619. $formatter = $this->getHelperSet()->get('debug_formatter');
  52620. $that = $this;
  52621. return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
  52622. $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
  52623. if (null !== $callback) {
  52624. \call_user_func($callback, $type, $buffer);
  52625. }
  52626. };
  52627. }
  52628. public function escapeString($str)
  52629. {
  52630. return str_replace('<', '\\<', $str);
  52631. }
  52632. public function getName()
  52633. {
  52634. return 'process';
  52635. }
  52636. }
  52637. <?php
  52638. namespace Symfony\Component\Console\Helper;
  52639. use Symfony\Component\Console\Exception\LogicException;
  52640. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  52641. use Symfony\Component\Console\Output\OutputInterface;
  52642. class ProgressBar
  52643. {
  52644. private $barWidth = 28;
  52645. private $barChar;
  52646. private $emptyBarChar = '-';
  52647. private $progressChar = '>';
  52648. private $format;
  52649. private $internalFormat;
  52650. private $redrawFreq = 1;
  52651. private $output;
  52652. private $step = 0;
  52653. private $max;
  52654. private $startTime;
  52655. private $stepWidth;
  52656. private $percent = 0.0;
  52657. private $formatLineCount;
  52658. private $messages = array();
  52659. private $overwrite = true;
  52660. private $firstRun = true;
  52661. private static $formatters;
  52662. private static $formats;
  52663. public function __construct(OutputInterface $output, $max = 0)
  52664. {
  52665. if ($output instanceof ConsoleOutputInterface) {
  52666. $output = $output->getErrorOutput();
  52667. }
  52668. $this->output = $output;
  52669. $this->setMaxSteps($max);
  52670. if (!$this->output->isDecorated()) {
  52671. $this->overwrite = false;
  52672. $this->setRedrawFrequency($max / 10);
  52673. }
  52674. $this->startTime = time();
  52675. }
  52676. public static function setPlaceholderFormatterDefinition($name, $callable)
  52677. {
  52678. if (!self::$formatters) {
  52679. self::$formatters = self::initPlaceholderFormatters();
  52680. }
  52681. self::$formatters[$name] = $callable;
  52682. }
  52683. public static function getPlaceholderFormatterDefinition($name)
  52684. {
  52685. if (!self::$formatters) {
  52686. self::$formatters = self::initPlaceholderFormatters();
  52687. }
  52688. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  52689. }
  52690. public static function setFormatDefinition($name, $format)
  52691. {
  52692. if (!self::$formats) {
  52693. self::$formats = self::initFormats();
  52694. }
  52695. self::$formats[$name] = $format;
  52696. }
  52697. public static function getFormatDefinition($name)
  52698. {
  52699. if (!self::$formats) {
  52700. self::$formats = self::initFormats();
  52701. }
  52702. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  52703. }
  52704. public function setMessage($message, $name = 'message')
  52705. {
  52706. $this->messages[$name] = $message;
  52707. }
  52708. public function getMessage($name = 'message')
  52709. {
  52710. return $this->messages[$name];
  52711. }
  52712. public function getStartTime()
  52713. {
  52714. return $this->startTime;
  52715. }
  52716. public function getMaxSteps()
  52717. {
  52718. return $this->max;
  52719. }
  52720. public function getStep()
  52721. {
  52722. @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);
  52723. return $this->getProgress();
  52724. }
  52725. public function getProgress()
  52726. {
  52727. return $this->step;
  52728. }
  52729. public function getStepWidth()
  52730. {
  52731. return $this->stepWidth;
  52732. }
  52733. public function getProgressPercent()
  52734. {
  52735. return $this->percent;
  52736. }
  52737. public function setBarWidth($size)
  52738. {
  52739. $this->barWidth = (int) $size;
  52740. }
  52741. public function getBarWidth()
  52742. {
  52743. return $this->barWidth;
  52744. }
  52745. public function setBarCharacter($char)
  52746. {
  52747. $this->barChar = $char;
  52748. }
  52749. public function getBarCharacter()
  52750. {
  52751. if (null === $this->barChar) {
  52752. return $this->max ? '=' : $this->emptyBarChar;
  52753. }
  52754. return $this->barChar;
  52755. }
  52756. public function setEmptyBarCharacter($char)
  52757. {
  52758. $this->emptyBarChar = $char;
  52759. }
  52760. public function getEmptyBarCharacter()
  52761. {
  52762. return $this->emptyBarChar;
  52763. }
  52764. public function setProgressCharacter($char)
  52765. {
  52766. $this->progressChar = $char;
  52767. }
  52768. public function getProgressCharacter()
  52769. {
  52770. return $this->progressChar;
  52771. }
  52772. public function setFormat($format)
  52773. {
  52774. $this->format = null;
  52775. $this->internalFormat = $format;
  52776. }
  52777. public function setRedrawFrequency($freq)
  52778. {
  52779. $this->redrawFreq = max((int) $freq, 1);
  52780. }
  52781. public function start($max = null)
  52782. {
  52783. $this->startTime = time();
  52784. $this->step = 0;
  52785. $this->percent = 0.0;
  52786. if (null !== $max) {
  52787. $this->setMaxSteps($max);
  52788. }
  52789. $this->display();
  52790. }
  52791. public function advance($step = 1)
  52792. {
  52793. $this->setProgress($this->step + $step);
  52794. }
  52795. public function setCurrent($step)
  52796. {
  52797. @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);
  52798. $this->setProgress($step);
  52799. }
  52800. public function setOverwrite($overwrite)
  52801. {
  52802. $this->overwrite = (bool) $overwrite;
  52803. }
  52804. public function setProgress($step)
  52805. {
  52806. $step = (int) $step;
  52807. if ($step < $this->step) {
  52808. throw new LogicException('You can\'t regress the progress bar.');
  52809. }
  52810. if ($this->max && $step > $this->max) {
  52811. $this->max = $step;
  52812. }
  52813. $prevPeriod = (int) ($this->step / $this->redrawFreq);
  52814. $currPeriod = (int) ($step / $this->redrawFreq);
  52815. $this->step = $step;
  52816. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  52817. if ($prevPeriod !== $currPeriod || $this->max === $step) {
  52818. $this->display();
  52819. }
  52820. }
  52821. public function finish()
  52822. {
  52823. if (!$this->max) {
  52824. $this->max = $this->step;
  52825. }
  52826. if ($this->step === $this->max && !$this->overwrite) {
  52827. return;
  52828. }
  52829. $this->setProgress($this->max);
  52830. }
  52831. public function display()
  52832. {
  52833. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  52834. return;
  52835. }
  52836. if (null === $this->format) {
  52837. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  52838. }
  52839. $self = $this;
  52840. $output = $this->output;
  52841. $messages = $this->messages;
  52842. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) {
  52843. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  52844. $text = \call_user_func($formatter, $self, $output);
  52845. } elseif (isset($messages[$matches[1]])) {
  52846. $text = $messages[$matches[1]];
  52847. } else {
  52848. return $matches[0];
  52849. }
  52850. if (isset($matches[2])) {
  52851. $text = sprintf('%'.$matches[2], $text);
  52852. }
  52853. return $text;
  52854. }, $this->format));
  52855. }
  52856. public function clear()
  52857. {
  52858. if (!$this->overwrite) {
  52859. return;
  52860. }
  52861. if (null === $this->format) {
  52862. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  52863. }
  52864. $this->overwrite('');
  52865. }
  52866. private function setRealFormat($format)
  52867. {
  52868. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  52869. $this->format = self::getFormatDefinition($format.'_nomax');
  52870. } elseif (null !== self::getFormatDefinition($format)) {
  52871. $this->format = self::getFormatDefinition($format);
  52872. } else {
  52873. $this->format = $format;
  52874. }
  52875. $this->formatLineCount = substr_count($this->format, "\n");
  52876. }
  52877. private function setMaxSteps($max)
  52878. {
  52879. $this->max = max(0, (int) $max);
  52880. $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
  52881. }
  52882. private function overwrite($message)
  52883. {
  52884. if ($this->overwrite) {
  52885. if (!$this->firstRun) {
  52886. $this->output->write("\x0D");
  52887. $this->output->write("\x1B[2K");
  52888. if ($this->formatLineCount > 0) {
  52889. $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
  52890. }
  52891. }
  52892. } elseif ($this->step > 0) {
  52893. $this->output->writeln('');
  52894. }
  52895. $this->firstRun = false;
  52896. $this->output->write($message);
  52897. }
  52898. private function determineBestFormat()
  52899. {
  52900. switch ($this->output->getVerbosity()) {
  52901. case OutputInterface::VERBOSITY_VERBOSE:
  52902. return $this->max ? 'verbose' : 'verbose_nomax';
  52903. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  52904. return $this->max ? 'very_verbose' : 'very_verbose_nomax';
  52905. case OutputInterface::VERBOSITY_DEBUG:
  52906. return $this->max ? 'debug' : 'debug_nomax';
  52907. default:
  52908. return $this->max ? 'normal' : 'normal_nomax';
  52909. }
  52910. }
  52911. private static function initPlaceholderFormatters()
  52912. {
  52913. return array(
  52914. 'bar' => function (ProgressBar $bar, OutputInterface $output) {
  52915. $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth());
  52916. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  52917. if ($completeBars < $bar->getBarWidth()) {
  52918. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
  52919. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  52920. }
  52921. return $display;
  52922. },
  52923. 'elapsed' => function (ProgressBar $bar) {
  52924. return Helper::formatTime(time() - $bar->getStartTime());
  52925. },
  52926. 'remaining' => function (ProgressBar $bar) {
  52927. if (!$bar->getMaxSteps()) {
  52928. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  52929. }
  52930. if (!$bar->getProgress()) {
  52931. $remaining = 0;
  52932. } else {
  52933. $remaining = round((time() - $bar->getStartTime()) / $bar->getProgress() * ($bar->getMaxSteps() - $bar->getProgress()));
  52934. }
  52935. return Helper::formatTime($remaining);
  52936. },
  52937. 'estimated' => function (ProgressBar $bar) {
  52938. if (!$bar->getMaxSteps()) {
  52939. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  52940. }
  52941. if (!$bar->getProgress()) {
  52942. $estimated = 0;
  52943. } else {
  52944. $estimated = round((time() - $bar->getStartTime()) / $bar->getProgress() * $bar->getMaxSteps());
  52945. }
  52946. return Helper::formatTime($estimated);
  52947. },
  52948. 'memory' => function (ProgressBar $bar) {
  52949. return Helper::formatMemory(memory_get_usage(true));
  52950. },
  52951. 'current' => function (ProgressBar $bar) {
  52952. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT);
  52953. },
  52954. 'max' => function (ProgressBar $bar) {
  52955. return $bar->getMaxSteps();
  52956. },
  52957. 'percent' => function (ProgressBar $bar) {
  52958. return floor($bar->getProgressPercent() * 100);
  52959. },
  52960. );
  52961. }
  52962. private static function initFormats()
  52963. {
  52964. return array(
  52965. 'normal' => ' %current%/%max% [%bar%] %percent:3s%%',
  52966. 'normal_nomax' => ' %current% [%bar%]',
  52967. 'verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  52968. 'verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  52969. 'very_verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  52970. 'very_verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  52971. 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  52972. 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  52973. );
  52974. }
  52975. }
  52976. <?php
  52977. namespace Symfony\Component\Console\Helper;
  52978. use Symfony\Component\Console\Exception\LogicException;
  52979. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  52980. use Symfony\Component\Console\Output\NullOutput;
  52981. use Symfony\Component\Console\Output\OutputInterface;
  52982. class ProgressHelper extends Helper
  52983. {
  52984. const FORMAT_QUIET = ' %percent%%';
  52985. const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
  52986. const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
  52987. const FORMAT_QUIET_NOMAX = ' %current%';
  52988. const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
  52989. const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
  52990. private $barWidth = 28;
  52991. private $barChar = '=';
  52992. private $emptyBarChar = '-';
  52993. private $progressChar = '>';
  52994. private $format = null;
  52995. private $redrawFreq = 1;
  52996. private $lastMessagesLength;
  52997. private $barCharOriginal;
  52998. private $output;
  52999. private $current;
  53000. private $max;
  53001. private $startTime;
  53002. private $defaultFormatVars = array(
  53003. 'current',
  53004. 'max',
  53005. 'bar',
  53006. 'percent',
  53007. 'elapsed',
  53008. );
  53009. private $formatVars;
  53010. private $widths = array(
  53011. 'current' => 4,
  53012. 'max' => 4,
  53013. 'percent' => 3,
  53014. 'elapsed' => 6,
  53015. );
  53016. private $timeFormats = array(
  53017. array(0, '???'),
  53018. array(2, '1 sec'),
  53019. array(59, 'secs', 1),
  53020. array(60, '1 min'),
  53021. array(3600, 'mins', 60),
  53022. array(5400, '1 hr'),
  53023. array(86400, 'hrs', 3600),
  53024. array(129600, '1 day'),
  53025. array(604800, 'days', 86400),
  53026. );
  53027. public function __construct($triggerDeprecationError = true)
  53028. {
  53029. if ($triggerDeprecationError) {
  53030. @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);
  53031. }
  53032. }
  53033. public function setBarWidth($size)
  53034. {
  53035. $this->barWidth = (int) $size;
  53036. }
  53037. public function setBarCharacter($char)
  53038. {
  53039. $this->barChar = $char;
  53040. }
  53041. public function setEmptyBarCharacter($char)
  53042. {
  53043. $this->emptyBarChar = $char;
  53044. }
  53045. public function setProgressCharacter($char)
  53046. {
  53047. $this->progressChar = $char;
  53048. }
  53049. public function setFormat($format)
  53050. {
  53051. $this->format = $format;
  53052. }
  53053. public function setRedrawFrequency($freq)
  53054. {
  53055. $this->redrawFreq = (int) $freq;
  53056. }
  53057. public function start(OutputInterface $output, $max = null)
  53058. {
  53059. if ($output instanceof ConsoleOutputInterface) {
  53060. $output = $output->getErrorOutput();
  53061. }
  53062. $this->startTime = time();
  53063. $this->current = 0;
  53064. $this->max = (int) $max;
  53065. $this->output = $output->isDecorated() ? $output : new NullOutput();
  53066. $this->lastMessagesLength = 0;
  53067. $this->barCharOriginal = '';
  53068. if (null === $this->format) {
  53069. switch ($output->getVerbosity()) {
  53070. case OutputInterface::VERBOSITY_QUIET:
  53071. $this->format = self::FORMAT_QUIET_NOMAX;
  53072. if ($this->max > 0) {
  53073. $this->format = self::FORMAT_QUIET;
  53074. }
  53075. break;
  53076. case OutputInterface::VERBOSITY_VERBOSE:
  53077. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  53078. case OutputInterface::VERBOSITY_DEBUG:
  53079. $this->format = self::FORMAT_VERBOSE_NOMAX;
  53080. if ($this->max > 0) {
  53081. $this->format = self::FORMAT_VERBOSE;
  53082. }
  53083. break;
  53084. default:
  53085. $this->format = self::FORMAT_NORMAL_NOMAX;
  53086. if ($this->max > 0) {
  53087. $this->format = self::FORMAT_NORMAL;
  53088. }
  53089. break;
  53090. }
  53091. }
  53092. $this->initialize();
  53093. }
  53094. public function advance($step = 1, $redraw = false)
  53095. {
  53096. $this->setCurrent($this->current + $step, $redraw);
  53097. }
  53098. public function setCurrent($current, $redraw = false)
  53099. {
  53100. if (null === $this->startTime) {
  53101. throw new LogicException('You must start the progress bar before calling setCurrent().');
  53102. }
  53103. $current = (int) $current;
  53104. if ($current < $this->current) {
  53105. throw new LogicException('You can\'t regress the progress bar');
  53106. }
  53107. if (0 === $this->current) {
  53108. $redraw = true;
  53109. }
  53110. $prevPeriod = (int) ($this->current / $this->redrawFreq);
  53111. $this->current = $current;
  53112. $currPeriod = (int) ($this->current / $this->redrawFreq);
  53113. if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
  53114. $this->display();
  53115. }
  53116. }
  53117. public function display($finish = false)
  53118. {
  53119. if (null === $this->startTime) {
  53120. throw new LogicException('You must start the progress bar before calling display().');
  53121. }
  53122. $message = $this->format;
  53123. foreach ($this->generate($finish) as $name => $value) {
  53124. $message = str_replace("%{$name}%", $value, $message);
  53125. }
  53126. $this->overwrite($this->output, $message);
  53127. }
  53128. public function clear()
  53129. {
  53130. $this->overwrite($this->output, '');
  53131. }
  53132. public function finish()
  53133. {
  53134. if (null === $this->startTime) {
  53135. throw new LogicException('You must start the progress bar before calling finish().');
  53136. }
  53137. if (null !== $this->startTime) {
  53138. if (!$this->max) {
  53139. $this->barChar = $this->barCharOriginal;
  53140. $this->display(true);
  53141. }
  53142. $this->startTime = null;
  53143. $this->output->writeln('');
  53144. $this->output = null;
  53145. }
  53146. }
  53147. private function initialize()
  53148. {
  53149. $this->formatVars = array();
  53150. foreach ($this->defaultFormatVars as $var) {
  53151. if (false !== strpos($this->format, "%{$var}%")) {
  53152. $this->formatVars[$var] = true;
  53153. }
  53154. }
  53155. if ($this->max > 0) {
  53156. $this->widths['max'] = $this->strlen($this->max);
  53157. $this->widths['current'] = $this->widths['max'];
  53158. } else {
  53159. $this->barCharOriginal = $this->barChar;
  53160. $this->barChar = $this->emptyBarChar;
  53161. }
  53162. }
  53163. private function generate($finish = false)
  53164. {
  53165. $vars = array();
  53166. $percent = 0;
  53167. if ($this->max > 0) {
  53168. $percent = (float) $this->current / $this->max;
  53169. }
  53170. if (isset($this->formatVars['bar'])) {
  53171. if ($this->max > 0) {
  53172. $completeBars = floor($percent * $this->barWidth);
  53173. } else {
  53174. if (!$finish) {
  53175. $completeBars = floor($this->current % $this->barWidth);
  53176. } else {
  53177. $completeBars = $this->barWidth;
  53178. }
  53179. }
  53180. $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
  53181. $bar = str_repeat($this->barChar, $completeBars);
  53182. if ($completeBars < $this->barWidth) {
  53183. $bar .= $this->progressChar;
  53184. $bar .= str_repeat($this->emptyBarChar, $emptyBars);
  53185. }
  53186. $vars['bar'] = $bar;
  53187. }
  53188. if (isset($this->formatVars['elapsed'])) {
  53189. $elapsed = time() - $this->startTime;
  53190. $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
  53191. }
  53192. if (isset($this->formatVars['current'])) {
  53193. $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
  53194. }
  53195. if (isset($this->formatVars['max'])) {
  53196. $vars['max'] = $this->max;
  53197. }
  53198. if (isset($this->formatVars['percent'])) {
  53199. $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
  53200. }
  53201. return $vars;
  53202. }
  53203. private function humaneTime($secs)
  53204. {
  53205. $text = '';
  53206. foreach ($this->timeFormats as $format) {
  53207. if ($secs < $format[0]) {
  53208. if (2 == \count($format)) {
  53209. $text = $format[1];
  53210. break;
  53211. } else {
  53212. $text = ceil($secs / $format[2]).' '.$format[1];
  53213. break;
  53214. }
  53215. }
  53216. }
  53217. return $text;
  53218. }
  53219. private function overwrite(OutputInterface $output, $message)
  53220. {
  53221. $length = $this->strlen($message);
  53222. if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
  53223. $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
  53224. }
  53225. $output->write("\x0D");
  53226. $output->write($message);
  53227. $this->lastMessagesLength = $this->strlen($message);
  53228. }
  53229. public function getName()
  53230. {
  53231. return 'progress';
  53232. }
  53233. }
  53234. <?php
  53235. namespace Symfony\Component\Console\Helper;
  53236. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53237. use Symfony\Component\Console\Exception\LogicException;
  53238. use Symfony\Component\Console\Output\OutputInterface;
  53239. class ProgressIndicator
  53240. {
  53241. private $output;
  53242. private $startTime;
  53243. private $format;
  53244. private $message;
  53245. private $indicatorValues;
  53246. private $indicatorCurrent;
  53247. private $indicatorChangeInterval;
  53248. private $indicatorUpdateTime;
  53249. private $started = false;
  53250. private static $formatters;
  53251. private static $formats;
  53252. public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null)
  53253. {
  53254. $this->output = $output;
  53255. if (null === $format) {
  53256. $format = $this->determineBestFormat();
  53257. }
  53258. if (null === $indicatorValues) {
  53259. $indicatorValues = array('-', '\\', '|', '/');
  53260. }
  53261. $indicatorValues = array_values($indicatorValues);
  53262. if (2 > \count($indicatorValues)) {
  53263. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  53264. }
  53265. $this->format = self::getFormatDefinition($format);
  53266. $this->indicatorChangeInterval = $indicatorChangeInterval;
  53267. $this->indicatorValues = $indicatorValues;
  53268. $this->startTime = time();
  53269. }
  53270. public function setMessage($message)
  53271. {
  53272. $this->message = $message;
  53273. $this->display();
  53274. }
  53275. public function getMessage()
  53276. {
  53277. return $this->message;
  53278. }
  53279. public function getStartTime()
  53280. {
  53281. return $this->startTime;
  53282. }
  53283. public function getCurrentValue()
  53284. {
  53285. return $this->indicatorValues[$this->indicatorCurrent % \count($this->indicatorValues)];
  53286. }
  53287. public function start($message)
  53288. {
  53289. if ($this->started) {
  53290. throw new LogicException('Progress indicator already started.');
  53291. }
  53292. $this->message = $message;
  53293. $this->started = true;
  53294. $this->startTime = time();
  53295. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  53296. $this->indicatorCurrent = 0;
  53297. $this->display();
  53298. }
  53299. public function advance()
  53300. {
  53301. if (!$this->started) {
  53302. throw new LogicException('Progress indicator has not yet been started.');
  53303. }
  53304. if (!$this->output->isDecorated()) {
  53305. return;
  53306. }
  53307. $currentTime = $this->getCurrentTimeInMilliseconds();
  53308. if ($currentTime < $this->indicatorUpdateTime) {
  53309. return;
  53310. }
  53311. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  53312. ++$this->indicatorCurrent;
  53313. $this->display();
  53314. }
  53315. public function finish($message)
  53316. {
  53317. if (!$this->started) {
  53318. throw new LogicException('Progress indicator has not yet been started.');
  53319. }
  53320. $this->message = $message;
  53321. $this->display();
  53322. $this->output->writeln('');
  53323. $this->started = false;
  53324. }
  53325. public static function getFormatDefinition($name)
  53326. {
  53327. if (!self::$formats) {
  53328. self::$formats = self::initFormats();
  53329. }
  53330. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  53331. }
  53332. public static function setPlaceholderFormatterDefinition($name, $callable)
  53333. {
  53334. if (!self::$formatters) {
  53335. self::$formatters = self::initPlaceholderFormatters();
  53336. }
  53337. self::$formatters[$name] = $callable;
  53338. }
  53339. public static function getPlaceholderFormatterDefinition($name)
  53340. {
  53341. if (!self::$formatters) {
  53342. self::$formatters = self::initPlaceholderFormatters();
  53343. }
  53344. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  53345. }
  53346. private function display()
  53347. {
  53348. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  53349. return;
  53350. }
  53351. $self = $this;
  53352. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
  53353. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  53354. return \call_user_func($formatter, $self);
  53355. }
  53356. return $matches[0];
  53357. }, $this->format));
  53358. }
  53359. private function determineBestFormat()
  53360. {
  53361. switch ($this->output->getVerbosity()) {
  53362. case OutputInterface::VERBOSITY_VERBOSE:
  53363. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  53364. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  53365. case OutputInterface::VERBOSITY_DEBUG:
  53366. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  53367. default:
  53368. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  53369. }
  53370. }
  53371. private function overwrite($message)
  53372. {
  53373. if ($this->output->isDecorated()) {
  53374. $this->output->write("\x0D\x1B[2K");
  53375. $this->output->write($message);
  53376. } else {
  53377. $this->output->writeln($message);
  53378. }
  53379. }
  53380. private function getCurrentTimeInMilliseconds()
  53381. {
  53382. return round(microtime(true) * 1000);
  53383. }
  53384. private static function initPlaceholderFormatters()
  53385. {
  53386. return array(
  53387. 'indicator' => function (ProgressIndicator $indicator) {
  53388. return $indicator->getCurrentValue();
  53389. },
  53390. 'message' => function (ProgressIndicator $indicator) {
  53391. return $indicator->getMessage();
  53392. },
  53393. 'elapsed' => function (ProgressIndicator $indicator) {
  53394. return Helper::formatTime(time() - $indicator->getStartTime());
  53395. },
  53396. 'memory' => function () {
  53397. return Helper::formatMemory(memory_get_usage(true));
  53398. },
  53399. );
  53400. }
  53401. private static function initFormats()
  53402. {
  53403. return array(
  53404. 'normal' => ' %indicator% %message%',
  53405. 'normal_no_ansi' => ' %message%',
  53406. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  53407. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  53408. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  53409. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  53410. );
  53411. }
  53412. }
  53413. <?php
  53414. namespace Symfony\Component\Console\Helper;
  53415. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53416. use Symfony\Component\Console\Exception\RuntimeException;
  53417. use Symfony\Component\Console\Formatter\OutputFormatter;
  53418. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  53419. use Symfony\Component\Console\Input\InputInterface;
  53420. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  53421. use Symfony\Component\Console\Output\OutputInterface;
  53422. use Symfony\Component\Console\Question\ChoiceQuestion;
  53423. use Symfony\Component\Console\Question\Question;
  53424. class QuestionHelper extends Helper
  53425. {
  53426. private $inputStream;
  53427. private static $shell;
  53428. private static $stty;
  53429. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  53430. {
  53431. if ($output instanceof ConsoleOutputInterface) {
  53432. $output = $output->getErrorOutput();
  53433. }
  53434. if (!$input->isInteractive()) {
  53435. $default = $question->getDefault();
  53436. if (null !== $default && $question instanceof ChoiceQuestion) {
  53437. $choices = $question->getChoices();
  53438. if (!$question->isMultiselect()) {
  53439. return isset($choices[$default]) ? $choices[$default] : $default;
  53440. }
  53441. $default = explode(',', $default);
  53442. foreach ($default as $k => $v) {
  53443. $v = trim($v);
  53444. $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
  53445. }
  53446. }
  53447. return $default;
  53448. }
  53449. if (!$question->getValidator()) {
  53450. return $this->doAsk($output, $question);
  53451. }
  53452. $that = $this;
  53453. $interviewer = function () use ($output, $question, $that) {
  53454. return $that->doAsk($output, $question);
  53455. };
  53456. return $this->validateAttempts($interviewer, $output, $question);
  53457. }
  53458. public function setInputStream($stream)
  53459. {
  53460. if (!\is_resource($stream)) {
  53461. throw new InvalidArgumentException('Input stream must be a valid resource.');
  53462. }
  53463. $this->inputStream = $stream;
  53464. }
  53465. public function getInputStream()
  53466. {
  53467. return $this->inputStream;
  53468. }
  53469. public function getName()
  53470. {
  53471. return 'question';
  53472. }
  53473. public function doAsk(OutputInterface $output, Question $question)
  53474. {
  53475. $this->writePrompt($output, $question);
  53476. $inputStream = $this->inputStream ?: STDIN;
  53477. $autocomplete = $question->getAutocompleterValues();
  53478. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  53479. $ret = false;
  53480. if ($question->isHidden()) {
  53481. try {
  53482. $ret = trim($this->getHiddenResponse($output, $inputStream));
  53483. } catch (RuntimeException $e) {
  53484. if (!$question->isHiddenFallback()) {
  53485. throw $e;
  53486. }
  53487. }
  53488. }
  53489. if (false === $ret) {
  53490. $ret = fgets($inputStream, 4096);
  53491. if (false === $ret) {
  53492. throw new RuntimeException('Aborted');
  53493. }
  53494. $ret = trim($ret);
  53495. }
  53496. } else {
  53497. $ret = trim($this->autocomplete($output, $question, $inputStream, \is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
  53498. }
  53499. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  53500. if ($normalizer = $question->getNormalizer()) {
  53501. return $normalizer($ret);
  53502. }
  53503. return $ret;
  53504. }
  53505. protected function writePrompt(OutputInterface $output, Question $question)
  53506. {
  53507. $message = $question->getQuestion();
  53508. if ($question instanceof ChoiceQuestion) {
  53509. $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
  53510. $messages = (array) $question->getQuestion();
  53511. foreach ($question->getChoices() as $key => $value) {
  53512. $width = $maxWidth - $this->strlen($key);
  53513. $messages[] = ' [<info>'.$key.str_repeat(' ', $width).'</info>] '.$value;
  53514. }
  53515. $output->writeln($messages);
  53516. $message = $question->getPrompt();
  53517. }
  53518. $output->write($message);
  53519. }
  53520. protected function writeError(OutputInterface $output, \Exception $error)
  53521. {
  53522. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  53523. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  53524. } else {
  53525. $message = '<error>'.$error->getMessage().'</error>';
  53526. }
  53527. $output->writeln($message);
  53528. }
  53529. private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
  53530. {
  53531. $ret = '';
  53532. $i = 0;
  53533. $ofs = -1;
  53534. $matches = $autocomplete;
  53535. $numMatches = \count($matches);
  53536. $sttyMode = shell_exec('stty -g');
  53537. shell_exec('stty -icanon -echo');
  53538. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  53539. while (!feof($inputStream)) {
  53540. $c = fread($inputStream, 1);
  53541. if ("\177" === $c) {
  53542. if (0 === $numMatches && 0 !== $i) {
  53543. --$i;
  53544. $output->write("\033[1D");
  53545. }
  53546. if (0 === $i) {
  53547. $ofs = -1;
  53548. $matches = $autocomplete;
  53549. $numMatches = \count($matches);
  53550. } else {
  53551. $numMatches = 0;
  53552. }
  53553. $ret = substr($ret, 0, $i);
  53554. } elseif ("\033" === $c) {
  53555. $c .= fread($inputStream, 2);
  53556. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  53557. if ('A' === $c[2] && -1 === $ofs) {
  53558. $ofs = 0;
  53559. }
  53560. if (0 === $numMatches) {
  53561. continue;
  53562. }
  53563. $ofs += ('A' === $c[2]) ? -1 : 1;
  53564. $ofs = ($numMatches + $ofs) % $numMatches;
  53565. }
  53566. } elseif (\ord($c) < 32) {
  53567. if ("\t" === $c || "\n" === $c) {
  53568. if ($numMatches > 0 && -1 !== $ofs) {
  53569. $ret = $matches[$ofs];
  53570. $output->write(substr($ret, $i));
  53571. $i = \strlen($ret);
  53572. }
  53573. if ("\n" === $c) {
  53574. $output->write($c);
  53575. break;
  53576. }
  53577. $numMatches = 0;
  53578. }
  53579. continue;
  53580. } else {
  53581. $output->write($c);
  53582. $ret .= $c;
  53583. ++$i;
  53584. $numMatches = 0;
  53585. $ofs = 0;
  53586. foreach ($autocomplete as $value) {
  53587. if (0 === strpos($value, $ret)) {
  53588. $matches[$numMatches++] = $value;
  53589. }
  53590. }
  53591. }
  53592. $output->write("\033[K");
  53593. if ($numMatches > 0 && -1 !== $ofs) {
  53594. $output->write("\0337");
  53595. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
  53596. $output->write("\0338");
  53597. }
  53598. }
  53599. shell_exec(sprintf('stty %s', $sttyMode));
  53600. return $ret;
  53601. }
  53602. private function getHiddenResponse(OutputInterface $output, $inputStream)
  53603. {
  53604. if ('\\' === \DIRECTORY_SEPARATOR) {
  53605. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  53606. if ('phar:' === substr(__FILE__, 0, 5)) {
  53607. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  53608. copy($exe, $tmpExe);
  53609. $exe = $tmpExe;
  53610. }
  53611. $value = rtrim(shell_exec($exe));
  53612. $output->writeln('');
  53613. if (isset($tmpExe)) {
  53614. unlink($tmpExe);
  53615. }
  53616. return $value;
  53617. }
  53618. if ($this->hasSttyAvailable()) {
  53619. $sttyMode = shell_exec('stty -g');
  53620. shell_exec('stty -echo');
  53621. $value = fgets($inputStream, 4096);
  53622. shell_exec(sprintf('stty %s', $sttyMode));
  53623. if (false === $value) {
  53624. throw new RuntimeException('Aborted');
  53625. }
  53626. $value = trim($value);
  53627. $output->writeln('');
  53628. return $value;
  53629. }
  53630. if (false !== $shell = $this->getShell()) {
  53631. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  53632. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  53633. $value = rtrim(shell_exec($command));
  53634. $output->writeln('');
  53635. return $value;
  53636. }
  53637. throw new RuntimeException('Unable to hide the response.');
  53638. }
  53639. private function validateAttempts($interviewer, OutputInterface $output, Question $question)
  53640. {
  53641. $error = null;
  53642. $attempts = $question->getMaxAttempts();
  53643. while (null === $attempts || $attempts--) {
  53644. if (null !== $error) {
  53645. $this->writeError($output, $error);
  53646. }
  53647. try {
  53648. return \call_user_func($question->getValidator(), $interviewer());
  53649. } catch (RuntimeException $e) {
  53650. throw $e;
  53651. } catch (\Exception $error) {
  53652. }
  53653. }
  53654. throw $error;
  53655. }
  53656. private function getShell()
  53657. {
  53658. if (null !== self::$shell) {
  53659. return self::$shell;
  53660. }
  53661. self::$shell = false;
  53662. if (file_exists('/usr/bin/env')) {
  53663. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  53664. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  53665. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  53666. self::$shell = $sh;
  53667. break;
  53668. }
  53669. }
  53670. }
  53671. return self::$shell;
  53672. }
  53673. private function hasSttyAvailable()
  53674. {
  53675. if (null !== self::$stty) {
  53676. return self::$stty;
  53677. }
  53678. exec('stty 2>&1', $output, $exitcode);
  53679. return self::$stty = 0 === $exitcode;
  53680. }
  53681. }
  53682. <?php
  53683. namespace Symfony\Component\Console\Helper;
  53684. use Symfony\Component\Console\Exception\LogicException;
  53685. use Symfony\Component\Console\Formatter\OutputFormatter;
  53686. use Symfony\Component\Console\Input\InputInterface;
  53687. use Symfony\Component\Console\Output\OutputInterface;
  53688. use Symfony\Component\Console\Question\ChoiceQuestion;
  53689. use Symfony\Component\Console\Question\ConfirmationQuestion;
  53690. use Symfony\Component\Console\Question\Question;
  53691. use Symfony\Component\Console\Style\SymfonyStyle;
  53692. class SymfonyQuestionHelper extends QuestionHelper
  53693. {
  53694. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  53695. {
  53696. $validator = $question->getValidator();
  53697. $question->setValidator(function ($value) use ($validator) {
  53698. if (null !== $validator) {
  53699. $value = $validator($value);
  53700. } else {
  53701. if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
  53702. throw new LogicException('A value is required.');
  53703. }
  53704. }
  53705. return $value;
  53706. });
  53707. return parent::ask($input, $output, $question);
  53708. }
  53709. protected function writePrompt(OutputInterface $output, Question $question)
  53710. {
  53711. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  53712. $default = $question->getDefault();
  53713. switch (true) {
  53714. case null === $default:
  53715. $text = sprintf(' <info>%s</info>:', $text);
  53716. break;
  53717. case $question instanceof ConfirmationQuestion:
  53718. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  53719. break;
  53720. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  53721. $choices = $question->getChoices();
  53722. $default = explode(',', $default);
  53723. foreach ($default as $key => $value) {
  53724. $default[$key] = $choices[trim($value)];
  53725. }
  53726. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  53727. break;
  53728. case $question instanceof ChoiceQuestion:
  53729. $choices = $question->getChoices();
  53730. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
  53731. break;
  53732. default:
  53733. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  53734. }
  53735. $output->writeln($text);
  53736. if ($question instanceof ChoiceQuestion) {
  53737. $width = max(array_map('strlen', array_keys($question->getChoices())));
  53738. foreach ($question->getChoices() as $key => $value) {
  53739. $output->writeln(sprintf(" [<comment>%-${width}s</comment>] %s", $key, $value));
  53740. }
  53741. }
  53742. $output->write(' > ');
  53743. }
  53744. protected function writeError(OutputInterface $output, \Exception $error)
  53745. {
  53746. if ($output instanceof SymfonyStyle) {
  53747. $output->newLine();
  53748. $output->error($error->getMessage());
  53749. return;
  53750. }
  53751. parent::writeError($output, $error);
  53752. }
  53753. }
  53754. <?php
  53755. namespace Symfony\Component\Console\Helper;
  53756. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53757. use Symfony\Component\Console\Output\OutputInterface;
  53758. class Table
  53759. {
  53760. private $headers = array();
  53761. private $rows = array();
  53762. private $columnWidths = array();
  53763. private $numberOfColumns;
  53764. private $output;
  53765. private $style;
  53766. private $columnStyles = array();
  53767. private static $styles;
  53768. public function __construct(OutputInterface $output)
  53769. {
  53770. $this->output = $output;
  53771. if (!self::$styles) {
  53772. self::$styles = self::initStyles();
  53773. }
  53774. $this->setStyle('default');
  53775. }
  53776. public static function setStyleDefinition($name, TableStyle $style)
  53777. {
  53778. if (!self::$styles) {
  53779. self::$styles = self::initStyles();
  53780. }
  53781. self::$styles[$name] = $style;
  53782. }
  53783. public static function getStyleDefinition($name)
  53784. {
  53785. if (!self::$styles) {
  53786. self::$styles = self::initStyles();
  53787. }
  53788. if (isset(self::$styles[$name])) {
  53789. return self::$styles[$name];
  53790. }
  53791. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  53792. }
  53793. public function setStyle($name)
  53794. {
  53795. $this->style = $this->resolveStyle($name);
  53796. return $this;
  53797. }
  53798. public function getStyle()
  53799. {
  53800. return $this->style;
  53801. }
  53802. public function setColumnStyle($columnIndex, $name)
  53803. {
  53804. $columnIndex = (int) $columnIndex;
  53805. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  53806. return $this;
  53807. }
  53808. public function getColumnStyle($columnIndex)
  53809. {
  53810. if (isset($this->columnStyles[$columnIndex])) {
  53811. return $this->columnStyles[$columnIndex];
  53812. }
  53813. return $this->getStyle();
  53814. }
  53815. public function setHeaders(array $headers)
  53816. {
  53817. $headers = array_values($headers);
  53818. if (!empty($headers) && !\is_array($headers[0])) {
  53819. $headers = array($headers);
  53820. }
  53821. $this->headers = $headers;
  53822. return $this;
  53823. }
  53824. public function setRows(array $rows)
  53825. {
  53826. $this->rows = array();
  53827. return $this->addRows($rows);
  53828. }
  53829. public function addRows(array $rows)
  53830. {
  53831. foreach ($rows as $row) {
  53832. $this->addRow($row);
  53833. }
  53834. return $this;
  53835. }
  53836. public function addRow($row)
  53837. {
  53838. if ($row instanceof TableSeparator) {
  53839. $this->rows[] = $row;
  53840. return $this;
  53841. }
  53842. if (!\is_array($row)) {
  53843. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  53844. }
  53845. $this->rows[] = array_values($row);
  53846. return $this;
  53847. }
  53848. public function setRow($column, array $row)
  53849. {
  53850. $this->rows[$column] = $row;
  53851. return $this;
  53852. }
  53853. public function render()
  53854. {
  53855. $this->calculateNumberOfColumns();
  53856. $rows = $this->buildTableRows($this->rows);
  53857. $headers = $this->buildTableRows($this->headers);
  53858. $this->calculateColumnsWidth(array_merge($headers, $rows));
  53859. $this->renderRowSeparator();
  53860. if (!empty($headers)) {
  53861. foreach ($headers as $header) {
  53862. $this->renderRow($header, $this->style->getCellHeaderFormat());
  53863. $this->renderRowSeparator();
  53864. }
  53865. }
  53866. foreach ($rows as $row) {
  53867. if ($row instanceof TableSeparator) {
  53868. $this->renderRowSeparator();
  53869. } else {
  53870. $this->renderRow($row, $this->style->getCellRowFormat());
  53871. }
  53872. }
  53873. if (!empty($rows)) {
  53874. $this->renderRowSeparator();
  53875. }
  53876. $this->cleanup();
  53877. }
  53878. private function renderRowSeparator()
  53879. {
  53880. if (0 === $count = $this->numberOfColumns) {
  53881. return;
  53882. }
  53883. if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) {
  53884. return;
  53885. }
  53886. $markup = $this->style->getCrossingChar();
  53887. for ($column = 0; $column < $count; ++$column) {
  53888. $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar();
  53889. }
  53890. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  53891. }
  53892. private function renderColumnSeparator()
  53893. {
  53894. return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
  53895. }
  53896. private function renderRow(array $row, $cellFormat)
  53897. {
  53898. if (empty($row)) {
  53899. return;
  53900. }
  53901. $rowContent = $this->renderColumnSeparator();
  53902. foreach ($this->getRowColumns($row) as $column) {
  53903. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  53904. $rowContent .= $this->renderColumnSeparator();
  53905. }
  53906. $this->output->writeln($rowContent);
  53907. }
  53908. private function renderCell(array $row, $column, $cellFormat)
  53909. {
  53910. $cell = isset($row[$column]) ? $row[$column] : '';
  53911. $width = $this->columnWidths[$column];
  53912. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  53913. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  53914. $width += $this->getColumnSeparatorWidth() + $this->columnWidths[$nextColumn];
  53915. }
  53916. }
  53917. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  53918. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  53919. }
  53920. $style = $this->getColumnStyle($column);
  53921. if ($cell instanceof TableSeparator) {
  53922. return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
  53923. }
  53924. $width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  53925. $content = sprintf($style->getCellRowContentFormat(), $cell);
  53926. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType()));
  53927. }
  53928. private function calculateNumberOfColumns()
  53929. {
  53930. if (null !== $this->numberOfColumns) {
  53931. return;
  53932. }
  53933. $columns = array(0);
  53934. foreach (array_merge($this->headers, $this->rows) as $row) {
  53935. if ($row instanceof TableSeparator) {
  53936. continue;
  53937. }
  53938. $columns[] = $this->getNumberOfColumns($row);
  53939. }
  53940. $this->numberOfColumns = max($columns);
  53941. }
  53942. private function buildTableRows($rows)
  53943. {
  53944. $unmergedRows = array();
  53945. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  53946. $rows = $this->fillNextRows($rows, $rowKey);
  53947. foreach ($rows[$rowKey] as $column => $cell) {
  53948. if (!strstr($cell, "\n")) {
  53949. continue;
  53950. }
  53951. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  53952. foreach ($lines as $lineKey => $line) {
  53953. if ($cell instanceof TableCell) {
  53954. $line = new TableCell($line, array('colspan' => $cell->getColspan()));
  53955. }
  53956. if (0 === $lineKey) {
  53957. $rows[$rowKey][$column] = $line;
  53958. } else {
  53959. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  53960. }
  53961. }
  53962. }
  53963. }
  53964. $tableRows = array();
  53965. foreach ($rows as $rowKey => $row) {
  53966. $tableRows[] = $this->fillCells($row);
  53967. if (isset($unmergedRows[$rowKey])) {
  53968. $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
  53969. }
  53970. }
  53971. return $tableRows;
  53972. }
  53973. private function fillNextRows(array $rows, $line)
  53974. {
  53975. $unmergedRows = array();
  53976. foreach ($rows[$line] as $column => $cell) {
  53977. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  53978. $nbLines = $cell->getRowspan() - 1;
  53979. $lines = array($cell);
  53980. if (strstr($cell, "\n")) {
  53981. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  53982. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  53983. $rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
  53984. unset($lines[0]);
  53985. }
  53986. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows);
  53987. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  53988. $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
  53989. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
  53990. if ($nbLines === $unmergedRowKey - $line) {
  53991. break;
  53992. }
  53993. }
  53994. }
  53995. }
  53996. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  53997. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  53998. foreach ($unmergedRow as $cellKey => $cell) {
  53999. array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
  54000. }
  54001. } else {
  54002. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  54003. foreach ($unmergedRow as $column => $cell) {
  54004. if (!empty($cell)) {
  54005. $row[$column] = $unmergedRow[$column];
  54006. }
  54007. }
  54008. array_splice($rows, $unmergedRowKey, 0, array($row));
  54009. }
  54010. }
  54011. return $rows;
  54012. }
  54013. private function fillCells($row)
  54014. {
  54015. $newRow = array();
  54016. foreach ($row as $column => $cell) {
  54017. $newRow[] = $cell;
  54018. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  54019. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  54020. $newRow[] = '';
  54021. }
  54022. }
  54023. }
  54024. return $newRow ?: $row;
  54025. }
  54026. private function copyRow(array $rows, $line)
  54027. {
  54028. $row = $rows[$line];
  54029. foreach ($row as $cellKey => $cellValue) {
  54030. $row[$cellKey] = '';
  54031. if ($cellValue instanceof TableCell) {
  54032. $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan()));
  54033. }
  54034. }
  54035. return $row;
  54036. }
  54037. private function getNumberOfColumns(array $row)
  54038. {
  54039. $columns = \count($row);
  54040. foreach ($row as $column) {
  54041. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  54042. }
  54043. return $columns;
  54044. }
  54045. private function getRowColumns(array $row)
  54046. {
  54047. $columns = range(0, $this->numberOfColumns - 1);
  54048. foreach ($row as $cellKey => $cell) {
  54049. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  54050. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  54051. }
  54052. }
  54053. return $columns;
  54054. }
  54055. private function calculateColumnsWidth($rows)
  54056. {
  54057. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  54058. $lengths = array();
  54059. foreach ($rows as $row) {
  54060. if ($row instanceof TableSeparator) {
  54061. continue;
  54062. }
  54063. foreach ($row as $i => $cell) {
  54064. if ($cell instanceof TableCell) {
  54065. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  54066. $textLength = Helper::strlen($textContent);
  54067. if ($textLength > 0) {
  54068. $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
  54069. foreach ($contentColumns as $position => $content) {
  54070. $row[$i + $position] = $content;
  54071. }
  54072. }
  54073. }
  54074. }
  54075. $lengths[] = $this->getCellWidth($row, $column);
  54076. }
  54077. $this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
  54078. }
  54079. }
  54080. private function getColumnSeparatorWidth()
  54081. {
  54082. return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
  54083. }
  54084. private function getCellWidth(array $row, $column)
  54085. {
  54086. if (isset($row[$column])) {
  54087. $cell = $row[$column];
  54088. $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  54089. return $cellWidth;
  54090. }
  54091. return 0;
  54092. }
  54093. private function cleanup()
  54094. {
  54095. $this->columnWidths = array();
  54096. $this->numberOfColumns = null;
  54097. }
  54098. private static function initStyles()
  54099. {
  54100. $borderless = new TableStyle();
  54101. $borderless
  54102. ->setHorizontalBorderChar('=')
  54103. ->setVerticalBorderChar(' ')
  54104. ->setCrossingChar(' ')
  54105. ;
  54106. $compact = new TableStyle();
  54107. $compact
  54108. ->setHorizontalBorderChar('')
  54109. ->setVerticalBorderChar(' ')
  54110. ->setCrossingChar('')
  54111. ->setCellRowContentFormat('%s')
  54112. ;
  54113. $styleGuide = new TableStyle();
  54114. $styleGuide
  54115. ->setHorizontalBorderChar('-')
  54116. ->setVerticalBorderChar(' ')
  54117. ->setCrossingChar(' ')
  54118. ->setCellHeaderFormat('%s')
  54119. ;
  54120. return array(
  54121. 'default' => new TableStyle(),
  54122. 'borderless' => $borderless,
  54123. 'compact' => $compact,
  54124. 'symfony-style-guide' => $styleGuide,
  54125. );
  54126. }
  54127. private function resolveStyle($name)
  54128. {
  54129. if ($name instanceof TableStyle) {
  54130. return $name;
  54131. }
  54132. if (isset(self::$styles[$name])) {
  54133. return self::$styles[$name];
  54134. }
  54135. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  54136. }
  54137. }
  54138. <?php
  54139. namespace Symfony\Component\Console\Helper;
  54140. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54141. class TableCell
  54142. {
  54143. private $value;
  54144. private $options = array(
  54145. 'rowspan' => 1,
  54146. 'colspan' => 1,
  54147. );
  54148. public function __construct($value = '', array $options = array())
  54149. {
  54150. if (is_numeric($value) && !\is_string($value)) {
  54151. $value = (string) $value;
  54152. }
  54153. $this->value = $value;
  54154. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  54155. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  54156. }
  54157. $this->options = array_merge($this->options, $options);
  54158. }
  54159. public function __toString()
  54160. {
  54161. return $this->value;
  54162. }
  54163. public function getColspan()
  54164. {
  54165. return (int) $this->options['colspan'];
  54166. }
  54167. public function getRowspan()
  54168. {
  54169. return (int) $this->options['rowspan'];
  54170. }
  54171. }
  54172. <?php
  54173. namespace Symfony\Component\Console\Helper;
  54174. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54175. use Symfony\Component\Console\Output\NullOutput;
  54176. use Symfony\Component\Console\Output\OutputInterface;
  54177. class TableHelper extends Helper
  54178. {
  54179. const LAYOUT_DEFAULT = 0;
  54180. const LAYOUT_BORDERLESS = 1;
  54181. const LAYOUT_COMPACT = 2;
  54182. private $table;
  54183. public function __construct($triggerDeprecationError = true)
  54184. {
  54185. if ($triggerDeprecationError) {
  54186. @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);
  54187. }
  54188. $this->table = new Table(new NullOutput());
  54189. }
  54190. public function setLayout($layout)
  54191. {
  54192. switch ($layout) {
  54193. case self::LAYOUT_BORDERLESS:
  54194. $this->table->setStyle('borderless');
  54195. break;
  54196. case self::LAYOUT_COMPACT:
  54197. $this->table->setStyle('compact');
  54198. break;
  54199. case self::LAYOUT_DEFAULT:
  54200. $this->table->setStyle('default');
  54201. break;
  54202. default:
  54203. throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
  54204. }
  54205. return $this;
  54206. }
  54207. public function setHeaders(array $headers)
  54208. {
  54209. $this->table->setHeaders($headers);
  54210. return $this;
  54211. }
  54212. public function setRows(array $rows)
  54213. {
  54214. $this->table->setRows($rows);
  54215. return $this;
  54216. }
  54217. public function addRows(array $rows)
  54218. {
  54219. $this->table->addRows($rows);
  54220. return $this;
  54221. }
  54222. public function addRow(array $row)
  54223. {
  54224. $this->table->addRow($row);
  54225. return $this;
  54226. }
  54227. public function setRow($column, array $row)
  54228. {
  54229. $this->table->setRow($column, $row);
  54230. return $this;
  54231. }
  54232. public function setPaddingChar($paddingChar)
  54233. {
  54234. $this->table->getStyle()->setPaddingChar($paddingChar);
  54235. return $this;
  54236. }
  54237. public function setHorizontalBorderChar($horizontalBorderChar)
  54238. {
  54239. $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
  54240. return $this;
  54241. }
  54242. public function setVerticalBorderChar($verticalBorderChar)
  54243. {
  54244. $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
  54245. return $this;
  54246. }
  54247. public function setCrossingChar($crossingChar)
  54248. {
  54249. $this->table->getStyle()->setCrossingChar($crossingChar);
  54250. return $this;
  54251. }
  54252. public function setCellHeaderFormat($cellHeaderFormat)
  54253. {
  54254. $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
  54255. return $this;
  54256. }
  54257. public function setCellRowFormat($cellRowFormat)
  54258. {
  54259. $this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
  54260. return $this;
  54261. }
  54262. public function setCellRowContentFormat($cellRowContentFormat)
  54263. {
  54264. $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
  54265. return $this;
  54266. }
  54267. public function setBorderFormat($borderFormat)
  54268. {
  54269. $this->table->getStyle()->setBorderFormat($borderFormat);
  54270. return $this;
  54271. }
  54272. public function setPadType($padType)
  54273. {
  54274. $this->table->getStyle()->setPadType($padType);
  54275. return $this;
  54276. }
  54277. public function render(OutputInterface $output)
  54278. {
  54279. $p = new \ReflectionProperty($this->table, 'output');
  54280. $p->setAccessible(true);
  54281. $p->setValue($this->table, $output);
  54282. $this->table->render();
  54283. }
  54284. public function getName()
  54285. {
  54286. return 'table';
  54287. }
  54288. }
  54289. <?php
  54290. namespace Symfony\Component\Console\Helper;
  54291. class TableSeparator extends TableCell
  54292. {
  54293. public function __construct(array $options = array())
  54294. {
  54295. parent::__construct('', $options);
  54296. }
  54297. }
  54298. <?php
  54299. namespace Symfony\Component\Console\Helper;
  54300. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54301. use Symfony\Component\Console\Exception\LogicException;
  54302. class TableStyle
  54303. {
  54304. private $paddingChar = ' ';
  54305. private $horizontalBorderChar = '-';
  54306. private $verticalBorderChar = '|';
  54307. private $crossingChar = '+';
  54308. private $cellHeaderFormat = '<info>%s</info>';
  54309. private $cellRowFormat = '%s';
  54310. private $cellRowContentFormat = ' %s ';
  54311. private $borderFormat = '%s';
  54312. private $padType = STR_PAD_RIGHT;
  54313. public function setPaddingChar($paddingChar)
  54314. {
  54315. if (!$paddingChar) {
  54316. throw new LogicException('The padding char must not be empty');
  54317. }
  54318. $this->paddingChar = $paddingChar;
  54319. return $this;
  54320. }
  54321. public function getPaddingChar()
  54322. {
  54323. return $this->paddingChar;
  54324. }
  54325. public function setHorizontalBorderChar($horizontalBorderChar)
  54326. {
  54327. $this->horizontalBorderChar = $horizontalBorderChar;
  54328. return $this;
  54329. }
  54330. public function getHorizontalBorderChar()
  54331. {
  54332. return $this->horizontalBorderChar;
  54333. }
  54334. public function setVerticalBorderChar($verticalBorderChar)
  54335. {
  54336. $this->verticalBorderChar = $verticalBorderChar;
  54337. return $this;
  54338. }
  54339. public function getVerticalBorderChar()
  54340. {
  54341. return $this->verticalBorderChar;
  54342. }
  54343. public function setCrossingChar($crossingChar)
  54344. {
  54345. $this->crossingChar = $crossingChar;
  54346. return $this;
  54347. }
  54348. public function getCrossingChar()
  54349. {
  54350. return $this->crossingChar;
  54351. }
  54352. public function setCellHeaderFormat($cellHeaderFormat)
  54353. {
  54354. $this->cellHeaderFormat = $cellHeaderFormat;
  54355. return $this;
  54356. }
  54357. public function getCellHeaderFormat()
  54358. {
  54359. return $this->cellHeaderFormat;
  54360. }
  54361. public function setCellRowFormat($cellRowFormat)
  54362. {
  54363. $this->cellRowFormat = $cellRowFormat;
  54364. return $this;
  54365. }
  54366. public function getCellRowFormat()
  54367. {
  54368. return $this->cellRowFormat;
  54369. }
  54370. public function setCellRowContentFormat($cellRowContentFormat)
  54371. {
  54372. $this->cellRowContentFormat = $cellRowContentFormat;
  54373. return $this;
  54374. }
  54375. public function getCellRowContentFormat()
  54376. {
  54377. return $this->cellRowContentFormat;
  54378. }
  54379. public function setBorderFormat($borderFormat)
  54380. {
  54381. $this->borderFormat = $borderFormat;
  54382. return $this;
  54383. }
  54384. public function getBorderFormat()
  54385. {
  54386. return $this->borderFormat;
  54387. }
  54388. public function setPadType($padType)
  54389. {
  54390. if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
  54391. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  54392. }
  54393. $this->padType = $padType;
  54394. return $this;
  54395. }
  54396. public function getPadType()
  54397. {
  54398. return $this->padType;
  54399. }
  54400. }
  54401. <?php
  54402. namespace Symfony\Component\Console\Input;
  54403. use Symfony\Component\Console\Exception\RuntimeException;
  54404. class ArgvInput extends Input
  54405. {
  54406. private $tokens;
  54407. private $parsed;
  54408. public function __construct(array $argv = null, InputDefinition $definition = null)
  54409. {
  54410. if (null === $argv) {
  54411. $argv = $_SERVER['argv'];
  54412. }
  54413. array_shift($argv);
  54414. $this->tokens = $argv;
  54415. parent::__construct($definition);
  54416. }
  54417. protected function setTokens(array $tokens)
  54418. {
  54419. $this->tokens = $tokens;
  54420. }
  54421. protected function parse()
  54422. {
  54423. $parseOptions = true;
  54424. $this->parsed = $this->tokens;
  54425. while (null !== $token = array_shift($this->parsed)) {
  54426. if ($parseOptions && '' == $token) {
  54427. $this->parseArgument($token);
  54428. } elseif ($parseOptions && '--' == $token) {
  54429. $parseOptions = false;
  54430. } elseif ($parseOptions && 0 === strpos($token, '--')) {
  54431. $this->parseLongOption($token);
  54432. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  54433. $this->parseShortOption($token);
  54434. } else {
  54435. $this->parseArgument($token);
  54436. }
  54437. }
  54438. }
  54439. private function parseShortOption($token)
  54440. {
  54441. $name = substr($token, 1);
  54442. if (\strlen($name) > 1) {
  54443. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  54444. $this->addShortOption($name[0], substr($name, 1));
  54445. } else {
  54446. $this->parseShortOptionSet($name);
  54447. }
  54448. } else {
  54449. $this->addShortOption($name, null);
  54450. }
  54451. }
  54452. private function parseShortOptionSet($name)
  54453. {
  54454. $len = \strlen($name);
  54455. for ($i = 0; $i < $len; ++$i) {
  54456. if (!$this->definition->hasShortcut($name[$i])) {
  54457. $encoding = mb_detect_encoding($name, null, true);
  54458. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  54459. }
  54460. $option = $this->definition->getOptionForShortcut($name[$i]);
  54461. if ($option->acceptValue()) {
  54462. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  54463. break;
  54464. } else {
  54465. $this->addLongOption($option->getName(), null);
  54466. }
  54467. }
  54468. }
  54469. private function parseLongOption($token)
  54470. {
  54471. $name = substr($token, 2);
  54472. if (false !== $pos = strpos($name, '=')) {
  54473. if (0 === \strlen($value = substr($name, $pos + 1))) {
  54474. array_unshift($this->parsed, null);
  54475. }
  54476. $this->addLongOption(substr($name, 0, $pos), $value);
  54477. } else {
  54478. $this->addLongOption($name, null);
  54479. }
  54480. }
  54481. private function parseArgument($token)
  54482. {
  54483. $c = \count($this->arguments);
  54484. if ($this->definition->hasArgument($c)) {
  54485. $arg = $this->definition->getArgument($c);
  54486. $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;
  54487. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  54488. $arg = $this->definition->getArgument($c - 1);
  54489. $this->arguments[$arg->getName()][] = $token;
  54490. } else {
  54491. $all = $this->definition->getArguments();
  54492. if (\count($all)) {
  54493. throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
  54494. }
  54495. throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
  54496. }
  54497. }
  54498. private function addShortOption($shortcut, $value)
  54499. {
  54500. if (!$this->definition->hasShortcut($shortcut)) {
  54501. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  54502. }
  54503. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  54504. }
  54505. private function addLongOption($name, $value)
  54506. {
  54507. if (!$this->definition->hasOption($name)) {
  54508. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  54509. }
  54510. $option = $this->definition->getOption($name);
  54511. if (!isset($value[0])) {
  54512. $value = null;
  54513. }
  54514. if (null !== $value && !$option->acceptValue()) {
  54515. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  54516. }
  54517. if (null === $value && $option->acceptValue() && \count($this->parsed)) {
  54518. $next = array_shift($this->parsed);
  54519. if (isset($next[0]) && '-' !== $next[0]) {
  54520. $value = $next;
  54521. } elseif (empty($next)) {
  54522. $value = null;
  54523. } else {
  54524. array_unshift($this->parsed, $next);
  54525. }
  54526. }
  54527. if (null === $value) {
  54528. if ($option->isValueRequired()) {
  54529. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  54530. }
  54531. if (!$option->isArray()) {
  54532. $value = $option->isValueOptional() ? $option->getDefault() : true;
  54533. }
  54534. }
  54535. if ($option->isArray()) {
  54536. $this->options[$name][] = $value;
  54537. } else {
  54538. $this->options[$name] = $value;
  54539. }
  54540. }
  54541. public function getFirstArgument()
  54542. {
  54543. foreach ($this->tokens as $token) {
  54544. if ($token && '-' === $token[0]) {
  54545. continue;
  54546. }
  54547. return $token;
  54548. }
  54549. }
  54550. public function hasParameterOption($values)
  54551. {
  54552. $values = (array) $values;
  54553. foreach ($this->tokens as $token) {
  54554. foreach ($values as $value) {
  54555. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  54556. if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) {
  54557. return true;
  54558. }
  54559. }
  54560. }
  54561. return false;
  54562. }
  54563. public function getParameterOption($values, $default = false)
  54564. {
  54565. $values = (array) $values;
  54566. $tokens = $this->tokens;
  54567. while (0 < \count($tokens)) {
  54568. $token = array_shift($tokens);
  54569. foreach ($values as $value) {
  54570. if ($token === $value) {
  54571. return array_shift($tokens);
  54572. }
  54573. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  54574. if ('' !== $leading && 0 === strpos($token, $leading)) {
  54575. return substr($token, \strlen($leading));
  54576. }
  54577. }
  54578. }
  54579. return $default;
  54580. }
  54581. public function __toString()
  54582. {
  54583. $self = $this;
  54584. $tokens = array_map(function ($token) use ($self) {
  54585. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  54586. return $match[1].$self->escapeToken($match[2]);
  54587. }
  54588. if ($token && '-' !== $token[0]) {
  54589. return $self->escapeToken($token);
  54590. }
  54591. return $token;
  54592. }, $this->tokens);
  54593. return implode(' ', $tokens);
  54594. }
  54595. }
  54596. <?php
  54597. namespace Symfony\Component\Console\Input;
  54598. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54599. use Symfony\Component\Console\Exception\InvalidOptionException;
  54600. class ArrayInput extends Input
  54601. {
  54602. private $parameters;
  54603. public function __construct(array $parameters, InputDefinition $definition = null)
  54604. {
  54605. $this->parameters = $parameters;
  54606. parent::__construct($definition);
  54607. }
  54608. public function getFirstArgument()
  54609. {
  54610. foreach ($this->parameters as $key => $value) {
  54611. if ($key && '-' === $key[0]) {
  54612. continue;
  54613. }
  54614. return $value;
  54615. }
  54616. }
  54617. public function hasParameterOption($values)
  54618. {
  54619. $values = (array) $values;
  54620. foreach ($this->parameters as $k => $v) {
  54621. if (!\is_int($k)) {
  54622. $v = $k;
  54623. }
  54624. if (\in_array($v, $values)) {
  54625. return true;
  54626. }
  54627. }
  54628. return false;
  54629. }
  54630. public function getParameterOption($values, $default = false)
  54631. {
  54632. $values = (array) $values;
  54633. foreach ($this->parameters as $k => $v) {
  54634. if (\is_int($k)) {
  54635. if (\in_array($v, $values)) {
  54636. return true;
  54637. }
  54638. } elseif (\in_array($k, $values)) {
  54639. return $v;
  54640. }
  54641. }
  54642. return $default;
  54643. }
  54644. public function __toString()
  54645. {
  54646. $params = array();
  54647. foreach ($this->parameters as $param => $val) {
  54648. if ($param && '-' === $param[0]) {
  54649. if (\is_array($val)) {
  54650. foreach ($val as $v) {
  54651. $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
  54652. }
  54653. } else {
  54654. $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
  54655. }
  54656. } else {
  54657. $params[] = \is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val);
  54658. }
  54659. }
  54660. return implode(' ', $params);
  54661. }
  54662. protected function parse()
  54663. {
  54664. foreach ($this->parameters as $key => $value) {
  54665. if (0 === strpos($key, '--')) {
  54666. $this->addLongOption(substr($key, 2), $value);
  54667. } elseif ('-' === $key[0]) {
  54668. $this->addShortOption(substr($key, 1), $value);
  54669. } else {
  54670. $this->addArgument($key, $value);
  54671. }
  54672. }
  54673. }
  54674. private function addShortOption($shortcut, $value)
  54675. {
  54676. if (!$this->definition->hasShortcut($shortcut)) {
  54677. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  54678. }
  54679. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  54680. }
  54681. private function addLongOption($name, $value)
  54682. {
  54683. if (!$this->definition->hasOption($name)) {
  54684. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  54685. }
  54686. $option = $this->definition->getOption($name);
  54687. if (null === $value) {
  54688. if ($option->isValueRequired()) {
  54689. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  54690. }
  54691. $value = $option->isValueOptional() ? $option->getDefault() : true;
  54692. }
  54693. $this->options[$name] = $value;
  54694. }
  54695. private function addArgument($name, $value)
  54696. {
  54697. if (!$this->definition->hasArgument($name)) {
  54698. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  54699. }
  54700. $this->arguments[$name] = $value;
  54701. }
  54702. }
  54703. <?php
  54704. namespace Symfony\Component\Console\Input;
  54705. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54706. use Symfony\Component\Console\Exception\RuntimeException;
  54707. abstract class Input implements InputInterface
  54708. {
  54709. protected $definition;
  54710. protected $options = array();
  54711. protected $arguments = array();
  54712. protected $interactive = true;
  54713. public function __construct(InputDefinition $definition = null)
  54714. {
  54715. if (null === $definition) {
  54716. $this->definition = new InputDefinition();
  54717. } else {
  54718. $this->bind($definition);
  54719. $this->validate();
  54720. }
  54721. }
  54722. public function bind(InputDefinition $definition)
  54723. {
  54724. $this->arguments = array();
  54725. $this->options = array();
  54726. $this->definition = $definition;
  54727. $this->parse();
  54728. }
  54729. abstract protected function parse();
  54730. public function validate()
  54731. {
  54732. $definition = $this->definition;
  54733. $givenArguments = $this->arguments;
  54734. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  54735. return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  54736. });
  54737. if (\count($missingArguments) > 0) {
  54738. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  54739. }
  54740. }
  54741. public function isInteractive()
  54742. {
  54743. return $this->interactive;
  54744. }
  54745. public function setInteractive($interactive)
  54746. {
  54747. $this->interactive = (bool) $interactive;
  54748. }
  54749. public function getArguments()
  54750. {
  54751. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  54752. }
  54753. public function getArgument($name)
  54754. {
  54755. if (!$this->definition->hasArgument($name)) {
  54756. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  54757. }
  54758. return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
  54759. }
  54760. public function setArgument($name, $value)
  54761. {
  54762. if (!$this->definition->hasArgument($name)) {
  54763. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  54764. }
  54765. $this->arguments[$name] = $value;
  54766. }
  54767. public function hasArgument($name)
  54768. {
  54769. return $this->definition->hasArgument($name);
  54770. }
  54771. public function getOptions()
  54772. {
  54773. return array_merge($this->definition->getOptionDefaults(), $this->options);
  54774. }
  54775. public function getOption($name)
  54776. {
  54777. if (!$this->definition->hasOption($name)) {
  54778. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  54779. }
  54780. return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  54781. }
  54782. public function setOption($name, $value)
  54783. {
  54784. if (!$this->definition->hasOption($name)) {
  54785. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  54786. }
  54787. $this->options[$name] = $value;
  54788. }
  54789. public function hasOption($name)
  54790. {
  54791. return $this->definition->hasOption($name);
  54792. }
  54793. public function escapeToken($token)
  54794. {
  54795. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  54796. }
  54797. }
  54798. <?php
  54799. namespace Symfony\Component\Console\Input;
  54800. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54801. use Symfony\Component\Console\Exception\LogicException;
  54802. class InputArgument
  54803. {
  54804. const REQUIRED = 1;
  54805. const OPTIONAL = 2;
  54806. const IS_ARRAY = 4;
  54807. private $name;
  54808. private $mode;
  54809. private $default;
  54810. private $description;
  54811. public function __construct($name, $mode = null, $description = '', $default = null)
  54812. {
  54813. if (null === $mode) {
  54814. $mode = self::OPTIONAL;
  54815. } elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
  54816. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  54817. }
  54818. $this->name = $name;
  54819. $this->mode = $mode;
  54820. $this->description = $description;
  54821. $this->setDefault($default);
  54822. }
  54823. public function getName()
  54824. {
  54825. return $this->name;
  54826. }
  54827. public function isRequired()
  54828. {
  54829. return self::REQUIRED === (self::REQUIRED & $this->mode);
  54830. }
  54831. public function isArray()
  54832. {
  54833. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  54834. }
  54835. public function setDefault($default = null)
  54836. {
  54837. if (self::REQUIRED === $this->mode && null !== $default) {
  54838. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  54839. }
  54840. if ($this->isArray()) {
  54841. if (null === $default) {
  54842. $default = array();
  54843. } elseif (!\is_array($default)) {
  54844. throw new LogicException('A default value for an array argument must be an array.');
  54845. }
  54846. }
  54847. $this->default = $default;
  54848. }
  54849. public function getDefault()
  54850. {
  54851. return $this->default;
  54852. }
  54853. public function getDescription()
  54854. {
  54855. return $this->description;
  54856. }
  54857. }
  54858. <?php
  54859. namespace Symfony\Component\Console\Input;
  54860. interface InputAwareInterface
  54861. {
  54862. public function setInput(InputInterface $input);
  54863. }
  54864. <?php
  54865. namespace Symfony\Component\Console\Input;
  54866. use Symfony\Component\Console\Descriptor\TextDescriptor;
  54867. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  54868. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54869. use Symfony\Component\Console\Exception\LogicException;
  54870. use Symfony\Component\Console\Output\BufferedOutput;
  54871. class InputDefinition
  54872. {
  54873. private $arguments;
  54874. private $requiredCount;
  54875. private $hasAnArrayArgument = false;
  54876. private $hasOptional;
  54877. private $options;
  54878. private $shortcuts;
  54879. public function __construct(array $definition = array())
  54880. {
  54881. $this->setDefinition($definition);
  54882. }
  54883. public function setDefinition(array $definition)
  54884. {
  54885. $arguments = array();
  54886. $options = array();
  54887. foreach ($definition as $item) {
  54888. if ($item instanceof InputOption) {
  54889. $options[] = $item;
  54890. } else {
  54891. $arguments[] = $item;
  54892. }
  54893. }
  54894. $this->setArguments($arguments);
  54895. $this->setOptions($options);
  54896. }
  54897. public function setArguments($arguments = array())
  54898. {
  54899. $this->arguments = array();
  54900. $this->requiredCount = 0;
  54901. $this->hasOptional = false;
  54902. $this->hasAnArrayArgument = false;
  54903. $this->addArguments($arguments);
  54904. }
  54905. public function addArguments($arguments = array())
  54906. {
  54907. if (null !== $arguments) {
  54908. foreach ($arguments as $argument) {
  54909. $this->addArgument($argument);
  54910. }
  54911. }
  54912. }
  54913. public function addArgument(InputArgument $argument)
  54914. {
  54915. if (isset($this->arguments[$argument->getName()])) {
  54916. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  54917. }
  54918. if ($this->hasAnArrayArgument) {
  54919. throw new LogicException('Cannot add an argument after an array argument.');
  54920. }
  54921. if ($argument->isRequired() && $this->hasOptional) {
  54922. throw new LogicException('Cannot add a required argument after an optional one.');
  54923. }
  54924. if ($argument->isArray()) {
  54925. $this->hasAnArrayArgument = true;
  54926. }
  54927. if ($argument->isRequired()) {
  54928. ++$this->requiredCount;
  54929. } else {
  54930. $this->hasOptional = true;
  54931. }
  54932. $this->arguments[$argument->getName()] = $argument;
  54933. }
  54934. public function getArgument($name)
  54935. {
  54936. if (!$this->hasArgument($name)) {
  54937. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  54938. }
  54939. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  54940. return $arguments[$name];
  54941. }
  54942. public function hasArgument($name)
  54943. {
  54944. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  54945. return isset($arguments[$name]);
  54946. }
  54947. public function getArguments()
  54948. {
  54949. return $this->arguments;
  54950. }
  54951. public function getArgumentCount()
  54952. {
  54953. return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
  54954. }
  54955. public function getArgumentRequiredCount()
  54956. {
  54957. return $this->requiredCount;
  54958. }
  54959. public function getArgumentDefaults()
  54960. {
  54961. $values = array();
  54962. foreach ($this->arguments as $argument) {
  54963. $values[$argument->getName()] = $argument->getDefault();
  54964. }
  54965. return $values;
  54966. }
  54967. public function setOptions($options = array())
  54968. {
  54969. $this->options = array();
  54970. $this->shortcuts = array();
  54971. $this->addOptions($options);
  54972. }
  54973. public function addOptions($options = array())
  54974. {
  54975. foreach ($options as $option) {
  54976. $this->addOption($option);
  54977. }
  54978. }
  54979. public function addOption(InputOption $option)
  54980. {
  54981. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  54982. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  54983. }
  54984. if ($option->getShortcut()) {
  54985. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  54986. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  54987. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  54988. }
  54989. }
  54990. }
  54991. $this->options[$option->getName()] = $option;
  54992. if ($option->getShortcut()) {
  54993. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  54994. $this->shortcuts[$shortcut] = $option->getName();
  54995. }
  54996. }
  54997. }
  54998. public function getOption($name)
  54999. {
  55000. if (!$this->hasOption($name)) {
  55001. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  55002. }
  55003. return $this->options[$name];
  55004. }
  55005. public function hasOption($name)
  55006. {
  55007. return isset($this->options[$name]);
  55008. }
  55009. public function getOptions()
  55010. {
  55011. return $this->options;
  55012. }
  55013. public function hasShortcut($name)
  55014. {
  55015. return isset($this->shortcuts[$name]);
  55016. }
  55017. public function getOptionForShortcut($shortcut)
  55018. {
  55019. return $this->getOption($this->shortcutToName($shortcut));
  55020. }
  55021. public function getOptionDefaults()
  55022. {
  55023. $values = array();
  55024. foreach ($this->options as $option) {
  55025. $values[$option->getName()] = $option->getDefault();
  55026. }
  55027. return $values;
  55028. }
  55029. private function shortcutToName($shortcut)
  55030. {
  55031. if (!isset($this->shortcuts[$shortcut])) {
  55032. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  55033. }
  55034. return $this->shortcuts[$shortcut];
  55035. }
  55036. public function getSynopsis($short = false)
  55037. {
  55038. $elements = array();
  55039. if ($short && $this->getOptions()) {
  55040. $elements[] = '[options]';
  55041. } elseif (!$short) {
  55042. foreach ($this->getOptions() as $option) {
  55043. $value = '';
  55044. if ($option->acceptValue()) {
  55045. $value = sprintf(
  55046. ' %s%s%s',
  55047. $option->isValueOptional() ? '[' : '',
  55048. strtoupper($option->getName()),
  55049. $option->isValueOptional() ? ']' : ''
  55050. );
  55051. }
  55052. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  55053. $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
  55054. }
  55055. }
  55056. if (\count($elements) && $this->getArguments()) {
  55057. $elements[] = '[--]';
  55058. }
  55059. foreach ($this->getArguments() as $argument) {
  55060. $element = '<'.$argument->getName().'>';
  55061. if (!$argument->isRequired()) {
  55062. $element = '['.$element.']';
  55063. } elseif ($argument->isArray()) {
  55064. $element .= ' ('.$element.')';
  55065. }
  55066. if ($argument->isArray()) {
  55067. $element .= '...';
  55068. }
  55069. $elements[] = $element;
  55070. }
  55071. return implode(' ', $elements);
  55072. }
  55073. public function asText()
  55074. {
  55075. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  55076. $descriptor = new TextDescriptor();
  55077. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  55078. $descriptor->describe($output, $this, array('raw_output' => true));
  55079. return $output->fetch();
  55080. }
  55081. public function asXml($asDom = false)
  55082. {
  55083. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  55084. $descriptor = new XmlDescriptor();
  55085. if ($asDom) {
  55086. return $descriptor->getInputDefinitionDocument($this);
  55087. }
  55088. $output = new BufferedOutput();
  55089. $descriptor->describe($output, $this);
  55090. return $output->fetch();
  55091. }
  55092. }
  55093. <?php
  55094. namespace Symfony\Component\Console\Input;
  55095. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55096. use Symfony\Component\Console\Exception\RuntimeException;
  55097. interface InputInterface
  55098. {
  55099. public function getFirstArgument();
  55100. public function hasParameterOption($values);
  55101. public function getParameterOption($values, $default = false);
  55102. public function bind(InputDefinition $definition);
  55103. public function validate();
  55104. public function getArguments();
  55105. public function getArgument($name);
  55106. public function setArgument($name, $value);
  55107. public function hasArgument($name);
  55108. public function getOptions();
  55109. public function getOption($name);
  55110. public function setOption($name, $value);
  55111. public function hasOption($name);
  55112. public function isInteractive();
  55113. public function setInteractive($interactive);
  55114. }
  55115. <?php
  55116. namespace Symfony\Component\Console\Input;
  55117. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55118. use Symfony\Component\Console\Exception\LogicException;
  55119. class InputOption
  55120. {
  55121. const VALUE_NONE = 1;
  55122. const VALUE_REQUIRED = 2;
  55123. const VALUE_OPTIONAL = 4;
  55124. const VALUE_IS_ARRAY = 8;
  55125. private $name;
  55126. private $shortcut;
  55127. private $mode;
  55128. private $default;
  55129. private $description;
  55130. public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
  55131. {
  55132. if (0 === strpos($name, '--')) {
  55133. $name = substr($name, 2);
  55134. }
  55135. if (empty($name)) {
  55136. throw new InvalidArgumentException('An option name cannot be empty.');
  55137. }
  55138. if (empty($shortcut)) {
  55139. $shortcut = null;
  55140. }
  55141. if (null !== $shortcut) {
  55142. if (\is_array($shortcut)) {
  55143. $shortcut = implode('|', $shortcut);
  55144. }
  55145. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  55146. $shortcuts = array_filter($shortcuts);
  55147. $shortcut = implode('|', $shortcuts);
  55148. if (empty($shortcut)) {
  55149. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  55150. }
  55151. }
  55152. if (null === $mode) {
  55153. $mode = self::VALUE_NONE;
  55154. } elseif (!\is_int($mode) || $mode > 15 || $mode < 1) {
  55155. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  55156. }
  55157. $this->name = $name;
  55158. $this->shortcut = $shortcut;
  55159. $this->mode = $mode;
  55160. $this->description = $description;
  55161. if ($this->isArray() && !$this->acceptValue()) {
  55162. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  55163. }
  55164. $this->setDefault($default);
  55165. }
  55166. public function getShortcut()
  55167. {
  55168. return $this->shortcut;
  55169. }
  55170. public function getName()
  55171. {
  55172. return $this->name;
  55173. }
  55174. public function acceptValue()
  55175. {
  55176. return $this->isValueRequired() || $this->isValueOptional();
  55177. }
  55178. public function isValueRequired()
  55179. {
  55180. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  55181. }
  55182. public function isValueOptional()
  55183. {
  55184. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  55185. }
  55186. public function isArray()
  55187. {
  55188. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  55189. }
  55190. public function setDefault($default = null)
  55191. {
  55192. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  55193. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  55194. }
  55195. if ($this->isArray()) {
  55196. if (null === $default) {
  55197. $default = array();
  55198. } elseif (!\is_array($default)) {
  55199. throw new LogicException('A default value for an array option must be an array.');
  55200. }
  55201. }
  55202. $this->default = $this->acceptValue() ? $default : false;
  55203. }
  55204. public function getDefault()
  55205. {
  55206. return $this->default;
  55207. }
  55208. public function getDescription()
  55209. {
  55210. return $this->description;
  55211. }
  55212. public function equals(self $option)
  55213. {
  55214. return $option->getName() === $this->getName()
  55215. && $option->getShortcut() === $this->getShortcut()
  55216. && $option->getDefault() === $this->getDefault()
  55217. && $option->isArray() === $this->isArray()
  55218. && $option->isValueRequired() === $this->isValueRequired()
  55219. && $option->isValueOptional() === $this->isValueOptional()
  55220. ;
  55221. }
  55222. }
  55223. <?php
  55224. namespace Symfony\Component\Console\Input;
  55225. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55226. class StringInput extends ArgvInput
  55227. {
  55228. const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  55229. const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  55230. public function __construct($input, InputDefinition $definition = null)
  55231. {
  55232. if ($definition) {
  55233. @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);
  55234. }
  55235. parent::__construct(array(), null);
  55236. $this->setTokens($this->tokenize($input));
  55237. if (null !== $definition) {
  55238. $this->bind($definition);
  55239. }
  55240. }
  55241. private function tokenize($input)
  55242. {
  55243. $tokens = array();
  55244. $length = \strlen($input);
  55245. $cursor = 0;
  55246. while ($cursor < $length) {
  55247. if (preg_match('/\s+/A', $input, $match, null, $cursor)) {
  55248. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {
  55249. $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, \strlen($match[3]) - 2)));
  55250. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
  55251. $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
  55252. } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {
  55253. $tokens[] = stripcslashes($match[1]);
  55254. } else {
  55255. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));
  55256. }
  55257. $cursor += \strlen($match[0]);
  55258. }
  55259. return $tokens;
  55260. }
  55261. }
  55262. Copyright (c) 2004-2018 Fabien Potencier
  55263. Permission is hereby granted, free of charge, to any person obtaining a copy
  55264. of this software and associated documentation files (the "Software"), to deal
  55265. in the Software without restriction, including without limitation the rights
  55266. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  55267. copies of the Software, and to permit persons to whom the Software is furnished
  55268. to do so, subject to the following conditions:
  55269. The above copyright notice and this permission notice shall be included in all
  55270. copies or substantial portions of the Software.
  55271. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  55272. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  55273. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  55274. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  55275. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  55276. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  55277. THE SOFTWARE.
  55278. <?php
  55279. namespace Symfony\Component\Console\Logger;
  55280. use Psr\Log\AbstractLogger;
  55281. use Psr\Log\InvalidArgumentException;
  55282. use Psr\Log\LogLevel;
  55283. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  55284. use Symfony\Component\Console\Output\OutputInterface;
  55285. class ConsoleLogger extends AbstractLogger
  55286. {
  55287. const INFO = 'info';
  55288. const ERROR = 'error';
  55289. private $output;
  55290. private $verbosityLevelMap = array(
  55291. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  55292. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  55293. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  55294. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  55295. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  55296. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  55297. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  55298. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  55299. );
  55300. private $formatLevelMap = array(
  55301. LogLevel::EMERGENCY => self::ERROR,
  55302. LogLevel::ALERT => self::ERROR,
  55303. LogLevel::CRITICAL => self::ERROR,
  55304. LogLevel::ERROR => self::ERROR,
  55305. LogLevel::WARNING => self::INFO,
  55306. LogLevel::NOTICE => self::INFO,
  55307. LogLevel::INFO => self::INFO,
  55308. LogLevel::DEBUG => self::INFO,
  55309. );
  55310. public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
  55311. {
  55312. $this->output = $output;
  55313. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  55314. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  55315. }
  55316. public function log($level, $message, array $context = array())
  55317. {
  55318. if (!isset($this->verbosityLevelMap[$level])) {
  55319. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  55320. }
  55321. if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) {
  55322. $output = $this->output->getErrorOutput();
  55323. } else {
  55324. $output = $this->output;
  55325. }
  55326. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  55327. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
  55328. }
  55329. }
  55330. private function interpolate($message, array $context)
  55331. {
  55332. $replace = array();
  55333. foreach ($context as $key => $val) {
  55334. if (!\is_array($val) && (!\is_object($val) || method_exists($val, '__toString'))) {
  55335. $replace[sprintf('{%s}', $key)] = $val;
  55336. }
  55337. }
  55338. return strtr($message, $replace);
  55339. }
  55340. }
  55341. <?php
  55342. namespace Symfony\Component\Console\Output;
  55343. class BufferedOutput extends Output
  55344. {
  55345. private $buffer = '';
  55346. public function fetch()
  55347. {
  55348. $content = $this->buffer;
  55349. $this->buffer = '';
  55350. return $content;
  55351. }
  55352. protected function doWrite($message, $newline)
  55353. {
  55354. $this->buffer .= $message;
  55355. if ($newline) {
  55356. $this->buffer .= PHP_EOL;
  55357. }
  55358. }
  55359. }
  55360. <?php
  55361. namespace Symfony\Component\Console\Output;
  55362. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  55363. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  55364. {
  55365. private $stderr;
  55366. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  55367. {
  55368. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  55369. $actualDecorated = $this->isDecorated();
  55370. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  55371. if (null === $decorated) {
  55372. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  55373. }
  55374. }
  55375. public function setDecorated($decorated)
  55376. {
  55377. parent::setDecorated($decorated);
  55378. $this->stderr->setDecorated($decorated);
  55379. }
  55380. public function setFormatter(OutputFormatterInterface $formatter)
  55381. {
  55382. parent::setFormatter($formatter);
  55383. $this->stderr->setFormatter($formatter);
  55384. }
  55385. public function setVerbosity($level)
  55386. {
  55387. parent::setVerbosity($level);
  55388. $this->stderr->setVerbosity($level);
  55389. }
  55390. public function getErrorOutput()
  55391. {
  55392. return $this->stderr;
  55393. }
  55394. public function setErrorOutput(OutputInterface $error)
  55395. {
  55396. $this->stderr = $error;
  55397. }
  55398. protected function hasStdoutSupport()
  55399. {
  55400. return false === $this->isRunningOS400();
  55401. }
  55402. protected function hasStderrSupport()
  55403. {
  55404. return false === $this->isRunningOS400();
  55405. }
  55406. private function isRunningOS400()
  55407. {
  55408. $checks = array(
  55409. \function_exists('php_uname') ? php_uname('s') : '',
  55410. getenv('OSTYPE'),
  55411. PHP_OS,
  55412. );
  55413. return false !== stripos(implode(';', $checks), 'OS400');
  55414. }
  55415. private function openOutputStream()
  55416. {
  55417. $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
  55418. return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
  55419. }
  55420. private function openErrorStream()
  55421. {
  55422. $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
  55423. return fopen($errorStream, 'w');
  55424. }
  55425. }
  55426. <?php
  55427. namespace Symfony\Component\Console\Output;
  55428. interface ConsoleOutputInterface extends OutputInterface
  55429. {
  55430. public function getErrorOutput();
  55431. public function setErrorOutput(OutputInterface $error);
  55432. }
  55433. <?php
  55434. namespace Symfony\Component\Console\Output;
  55435. use Symfony\Component\Console\Formatter\OutputFormatter;
  55436. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  55437. class NullOutput implements OutputInterface
  55438. {
  55439. public function setFormatter(OutputFormatterInterface $formatter)
  55440. {
  55441. }
  55442. public function getFormatter()
  55443. {
  55444. return new OutputFormatter();
  55445. }
  55446. public function setDecorated($decorated)
  55447. {
  55448. }
  55449. public function isDecorated()
  55450. {
  55451. return false;
  55452. }
  55453. public function setVerbosity($level)
  55454. {
  55455. }
  55456. public function getVerbosity()
  55457. {
  55458. return self::VERBOSITY_QUIET;
  55459. }
  55460. public function isQuiet()
  55461. {
  55462. return true;
  55463. }
  55464. public function isVerbose()
  55465. {
  55466. return false;
  55467. }
  55468. public function isVeryVerbose()
  55469. {
  55470. return false;
  55471. }
  55472. public function isDebug()
  55473. {
  55474. return false;
  55475. }
  55476. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  55477. {
  55478. }
  55479. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  55480. {
  55481. }
  55482. }
  55483. <?php
  55484. namespace Symfony\Component\Console\Output;
  55485. use Symfony\Component\Console\Formatter\OutputFormatter;
  55486. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  55487. abstract class Output implements OutputInterface
  55488. {
  55489. private $verbosity;
  55490. private $formatter;
  55491. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
  55492. {
  55493. $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
  55494. $this->formatter = $formatter ?: new OutputFormatter();
  55495. $this->formatter->setDecorated($decorated);
  55496. }
  55497. public function setFormatter(OutputFormatterInterface $formatter)
  55498. {
  55499. $this->formatter = $formatter;
  55500. }
  55501. public function getFormatter()
  55502. {
  55503. return $this->formatter;
  55504. }
  55505. public function setDecorated($decorated)
  55506. {
  55507. $this->formatter->setDecorated($decorated);
  55508. }
  55509. public function isDecorated()
  55510. {
  55511. return $this->formatter->isDecorated();
  55512. }
  55513. public function setVerbosity($level)
  55514. {
  55515. $this->verbosity = (int) $level;
  55516. }
  55517. public function getVerbosity()
  55518. {
  55519. return $this->verbosity;
  55520. }
  55521. public function isQuiet()
  55522. {
  55523. return self::VERBOSITY_QUIET === $this->verbosity;
  55524. }
  55525. public function isVerbose()
  55526. {
  55527. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  55528. }
  55529. public function isVeryVerbose()
  55530. {
  55531. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  55532. }
  55533. public function isDebug()
  55534. {
  55535. return self::VERBOSITY_DEBUG <= $this->verbosity;
  55536. }
  55537. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  55538. {
  55539. $this->write($messages, true, $options);
  55540. }
  55541. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  55542. {
  55543. $messages = (array) $messages;
  55544. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  55545. $type = $types & $options ?: self::OUTPUT_NORMAL;
  55546. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  55547. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  55548. if ($verbosity > $this->getVerbosity()) {
  55549. return;
  55550. }
  55551. foreach ($messages as $message) {
  55552. switch ($type) {
  55553. case OutputInterface::OUTPUT_NORMAL:
  55554. $message = $this->formatter->format($message);
  55555. break;
  55556. case OutputInterface::OUTPUT_RAW:
  55557. break;
  55558. case OutputInterface::OUTPUT_PLAIN:
  55559. $message = strip_tags($this->formatter->format($message));
  55560. break;
  55561. }
  55562. $this->doWrite($message, $newline);
  55563. }
  55564. }
  55565. abstract protected function doWrite($message, $newline);
  55566. }
  55567. <?php
  55568. namespace Symfony\Component\Console\Output;
  55569. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  55570. interface OutputInterface
  55571. {
  55572. const VERBOSITY_QUIET = 16;
  55573. const VERBOSITY_NORMAL = 32;
  55574. const VERBOSITY_VERBOSE = 64;
  55575. const VERBOSITY_VERY_VERBOSE = 128;
  55576. const VERBOSITY_DEBUG = 256;
  55577. const OUTPUT_NORMAL = 1;
  55578. const OUTPUT_RAW = 2;
  55579. const OUTPUT_PLAIN = 4;
  55580. public function write($messages, $newline = false, $options = 0);
  55581. public function writeln($messages, $options = 0);
  55582. public function setVerbosity($level);
  55583. public function getVerbosity();
  55584. public function setDecorated($decorated);
  55585. public function isDecorated();
  55586. public function setFormatter(OutputFormatterInterface $formatter);
  55587. public function getFormatter();
  55588. }
  55589. <?php
  55590. namespace Symfony\Component\Console\Output;
  55591. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55592. use Symfony\Component\Console\Exception\RuntimeException;
  55593. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  55594. class StreamOutput extends Output
  55595. {
  55596. private $stream;
  55597. public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  55598. {
  55599. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  55600. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  55601. }
  55602. $this->stream = $stream;
  55603. if (null === $decorated) {
  55604. $decorated = $this->hasColorSupport();
  55605. }
  55606. parent::__construct($verbosity, $decorated, $formatter);
  55607. }
  55608. public function getStream()
  55609. {
  55610. return $this->stream;
  55611. }
  55612. protected function doWrite($message, $newline)
  55613. {
  55614. if ($newline) {
  55615. $message .= PHP_EOL;
  55616. }
  55617. if (false === @fwrite($this->stream, $message)) {
  55618. throw new RuntimeException('Unable to write output.');
  55619. }
  55620. fflush($this->stream);
  55621. }
  55622. protected function hasColorSupport()
  55623. {
  55624. if ('Hyper' === getenv('TERM_PROGRAM')) {
  55625. return true;
  55626. }
  55627. if (\DIRECTORY_SEPARATOR === '\\') {
  55628. return (\function_exists('sapi_windows_vt100_support')
  55629. && @sapi_windows_vt100_support($this->stream))
  55630. || false !== getenv('ANSICON')
  55631. || 'ON' === getenv('ConEmuANSI')
  55632. || 'xterm' === getenv('TERM');
  55633. }
  55634. if (\function_exists('stream_isatty')) {
  55635. return @stream_isatty($this->stream);
  55636. }
  55637. if (\function_exists('posix_isatty')) {
  55638. return @posix_isatty($this->stream);
  55639. }
  55640. $stat = @fstat($this->stream);
  55641. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  55642. }
  55643. }
  55644. <?php
  55645. namespace Symfony\Component\Console\Question;
  55646. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55647. class ChoiceQuestion extends Question
  55648. {
  55649. private $choices;
  55650. private $multiselect = false;
  55651. private $prompt = ' > ';
  55652. private $errorMessage = 'Value "%s" is invalid';
  55653. public function __construct($question, array $choices, $default = null)
  55654. {
  55655. if (!$choices) {
  55656. throw new \LogicException('Choice question must have at least 1 choice available.');
  55657. }
  55658. parent::__construct($question, $default);
  55659. $this->choices = $choices;
  55660. $this->setValidator($this->getDefaultValidator());
  55661. $this->setAutocompleterValues($choices);
  55662. }
  55663. public function getChoices()
  55664. {
  55665. return $this->choices;
  55666. }
  55667. public function setMultiselect($multiselect)
  55668. {
  55669. $this->multiselect = $multiselect;
  55670. $this->setValidator($this->getDefaultValidator());
  55671. return $this;
  55672. }
  55673. public function isMultiselect()
  55674. {
  55675. return $this->multiselect;
  55676. }
  55677. public function getPrompt()
  55678. {
  55679. return $this->prompt;
  55680. }
  55681. public function setPrompt($prompt)
  55682. {
  55683. $this->prompt = $prompt;
  55684. return $this;
  55685. }
  55686. public function setErrorMessage($errorMessage)
  55687. {
  55688. $this->errorMessage = $errorMessage;
  55689. $this->setValidator($this->getDefaultValidator());
  55690. return $this;
  55691. }
  55692. private function getDefaultValidator()
  55693. {
  55694. $choices = $this->choices;
  55695. $errorMessage = $this->errorMessage;
  55696. $multiselect = $this->multiselect;
  55697. $isAssoc = $this->isAssoc($choices);
  55698. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  55699. $selectedChoices = str_replace(' ', '', $selected);
  55700. if ($multiselect) {
  55701. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
  55702. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  55703. }
  55704. $selectedChoices = explode(',', $selectedChoices);
  55705. } else {
  55706. $selectedChoices = array($selected);
  55707. }
  55708. $multiselectChoices = array();
  55709. foreach ($selectedChoices as $value) {
  55710. $results = array();
  55711. foreach ($choices as $key => $choice) {
  55712. if ($choice === $value) {
  55713. $results[] = $key;
  55714. }
  55715. }
  55716. if (\count($results) > 1) {
  55717. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
  55718. }
  55719. $result = array_search($value, $choices);
  55720. if (!$isAssoc) {
  55721. if (false !== $result) {
  55722. $result = $choices[$result];
  55723. } elseif (isset($choices[$value])) {
  55724. $result = $choices[$value];
  55725. }
  55726. } elseif (false === $result && isset($choices[$value])) {
  55727. $result = $value;
  55728. }
  55729. if (false === $result) {
  55730. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  55731. }
  55732. $multiselectChoices[] = (string) $result;
  55733. }
  55734. if ($multiselect) {
  55735. return $multiselectChoices;
  55736. }
  55737. return current($multiselectChoices);
  55738. };
  55739. }
  55740. }
  55741. <?php
  55742. namespace Symfony\Component\Console\Question;
  55743. class ConfirmationQuestion extends Question
  55744. {
  55745. private $trueAnswerRegex;
  55746. public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
  55747. {
  55748. parent::__construct($question, (bool) $default);
  55749. $this->trueAnswerRegex = $trueAnswerRegex;
  55750. $this->setNormalizer($this->getDefaultNormalizer());
  55751. }
  55752. private function getDefaultNormalizer()
  55753. {
  55754. $default = $this->getDefault();
  55755. $regex = $this->trueAnswerRegex;
  55756. return function ($answer) use ($default, $regex) {
  55757. if (\is_bool($answer)) {
  55758. return $answer;
  55759. }
  55760. $answerIsTrue = (bool) preg_match($regex, $answer);
  55761. if (false === $default) {
  55762. return $answer && $answerIsTrue;
  55763. }
  55764. return !$answer || $answerIsTrue;
  55765. };
  55766. }
  55767. }
  55768. <?php
  55769. namespace Symfony\Component\Console\Question;
  55770. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55771. use Symfony\Component\Console\Exception\LogicException;
  55772. class Question
  55773. {
  55774. private $question;
  55775. private $attempts;
  55776. private $hidden = false;
  55777. private $hiddenFallback = true;
  55778. private $autocompleterValues;
  55779. private $validator;
  55780. private $default;
  55781. private $normalizer;
  55782. public function __construct($question, $default = null)
  55783. {
  55784. $this->question = $question;
  55785. $this->default = $default;
  55786. }
  55787. public function getQuestion()
  55788. {
  55789. return $this->question;
  55790. }
  55791. public function getDefault()
  55792. {
  55793. return $this->default;
  55794. }
  55795. public function isHidden()
  55796. {
  55797. return $this->hidden;
  55798. }
  55799. public function setHidden($hidden)
  55800. {
  55801. if ($this->autocompleterValues) {
  55802. throw new LogicException('A hidden question cannot use the autocompleter.');
  55803. }
  55804. $this->hidden = (bool) $hidden;
  55805. return $this;
  55806. }
  55807. public function isHiddenFallback()
  55808. {
  55809. return $this->hiddenFallback;
  55810. }
  55811. public function setHiddenFallback($fallback)
  55812. {
  55813. $this->hiddenFallback = (bool) $fallback;
  55814. return $this;
  55815. }
  55816. public function getAutocompleterValues()
  55817. {
  55818. return $this->autocompleterValues;
  55819. }
  55820. public function setAutocompleterValues($values)
  55821. {
  55822. if (\is_array($values)) {
  55823. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  55824. }
  55825. if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
  55826. throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.');
  55827. }
  55828. if ($this->hidden) {
  55829. throw new LogicException('A hidden question cannot use the autocompleter.');
  55830. }
  55831. $this->autocompleterValues = $values;
  55832. return $this;
  55833. }
  55834. public function setValidator($validator)
  55835. {
  55836. $this->validator = $validator;
  55837. return $this;
  55838. }
  55839. public function getValidator()
  55840. {
  55841. return $this->validator;
  55842. }
  55843. public function setMaxAttempts($attempts)
  55844. {
  55845. if (null !== $attempts && $attempts < 1) {
  55846. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  55847. }
  55848. $this->attempts = $attempts;
  55849. return $this;
  55850. }
  55851. public function getMaxAttempts()
  55852. {
  55853. return $this->attempts;
  55854. }
  55855. public function setNormalizer($normalizer)
  55856. {
  55857. $this->normalizer = $normalizer;
  55858. return $this;
  55859. }
  55860. public function getNormalizer()
  55861. {
  55862. return $this->normalizer;
  55863. }
  55864. protected function isAssoc($array)
  55865. {
  55866. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  55867. }
  55868. }
  55869. MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  55870. $�������Æ,Í;§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��������à�  ��
  55871. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  55872. ����������������� ��`.rdata����� ���
  55873. �����������������@��@.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
  55874. 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
  55875. 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
  55876. 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">
  55877. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  55878. <security>
  55879. <requestedPrivileges>
  55880. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  55881. </requestedPrivileges>
  55882. </security>
  55883. </trustInfo>
  55884. <dependency>
  55885. <dependentAssembly>
  55886. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  55887. </dependentAssembly>
  55888. </dependency>
  55889. </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
  55890. namespace Symfony\Component\Console;
  55891. use Symfony\Component\Console\Exception\RuntimeException;
  55892. use Symfony\Component\Console\Input\StringInput;
  55893. use Symfony\Component\Console\Output\ConsoleOutput;
  55894. use Symfony\Component\Process\PhpExecutableFinder;
  55895. use Symfony\Component\Process\ProcessBuilder;
  55896. class Shell
  55897. {
  55898. private $application;
  55899. private $history;
  55900. private $output;
  55901. private $hasReadline;
  55902. private $processIsolation = false;
  55903. public function __construct(Application $application)
  55904. {
  55905. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  55906. $this->hasReadline = \function_exists('readline');
  55907. $this->application = $application;
  55908. $this->history = getenv('HOME').'/.history_'.$application->getName();
  55909. $this->output = new ConsoleOutput();
  55910. }
  55911. public function run()
  55912. {
  55913. $this->application->setAutoExit(false);
  55914. $this->application->setCatchExceptions(true);
  55915. if ($this->hasReadline) {
  55916. readline_read_history($this->history);
  55917. readline_completion_function(array($this, 'autocompleter'));
  55918. }
  55919. $this->output->writeln($this->getHeader());
  55920. $php = null;
  55921. if ($this->processIsolation) {
  55922. $finder = new PhpExecutableFinder();
  55923. $php = $finder->find();
  55924. $this->output->writeln(<<<'EOF'
  55925. <info>Running with process isolation, you should consider this:</info>
  55926. * each command is executed as separate process,
  55927. * commands don't support interactivity, all params must be passed explicitly,
  55928. * commands output is not colorized.
  55929. EOF
  55930. );
  55931. }
  55932. while (true) {
  55933. $command = $this->readline();
  55934. if (false === $command) {
  55935. $this->output->writeln("\n");
  55936. break;
  55937. }
  55938. if ($this->hasReadline) {
  55939. readline_add_history($command);
  55940. readline_write_history($this->history);
  55941. }
  55942. if ($this->processIsolation) {
  55943. $pb = new ProcessBuilder();
  55944. $process = $pb
  55945. ->add($php)
  55946. ->add($_SERVER['argv'][0])
  55947. ->add($command)
  55948. ->inheritEnvironmentVariables(true)
  55949. ->getProcess()
  55950. ;
  55951. $output = $this->output;
  55952. $process->run(function ($type, $data) use ($output) {
  55953. $output->writeln($data);
  55954. });
  55955. $ret = $process->getExitCode();
  55956. } else {
  55957. $ret = $this->application->run(new StringInput($command), $this->output);
  55958. }
  55959. if (0 !== $ret) {
  55960. $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
  55961. }
  55962. }
  55963. }
  55964. protected function getHeader()
  55965. {
  55966. return <<<EOF
  55967. Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
  55968. At the prompt, type <comment>help</comment> for some help,
  55969. or <comment>list</comment> to get a list of available commands.
  55970. To exit the shell, type <comment>^D</comment>.
  55971. EOF;
  55972. }
  55973. protected function getPrompt()
  55974. {
  55975. return $this->output->getFormatter()->format($this->application->getName().' > ');
  55976. }
  55977. protected function getOutput()
  55978. {
  55979. return $this->output;
  55980. }
  55981. protected function getApplication()
  55982. {
  55983. return $this->application;
  55984. }
  55985. private function autocompleter($text)
  55986. {
  55987. $info = readline_info();
  55988. $text = substr($info['line_buffer'], 0, $info['end']);
  55989. if ($info['point'] !== $info['end']) {
  55990. return true;
  55991. }
  55992. if (false === strpos($text, ' ') || !$text) {
  55993. return array_keys($this->application->all());
  55994. }
  55995. try {
  55996. $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
  55997. } catch (\Exception $e) {
  55998. return true;
  55999. }
  56000. $list = array('--help');
  56001. foreach ($command->getDefinition()->getOptions() as $option) {
  56002. $list[] = '--'.$option->getName();
  56003. }
  56004. return $list;
  56005. }
  56006. private function readline()
  56007. {
  56008. if ($this->hasReadline) {
  56009. $line = readline($this->getPrompt());
  56010. } else {
  56011. $this->output->write($this->getPrompt());
  56012. $line = fgets(STDIN, 1024);
  56013. $line = (false === $line || '' === $line) ? false : rtrim($line);
  56014. }
  56015. return $line;
  56016. }
  56017. public function getProcessIsolation()
  56018. {
  56019. return $this->processIsolation;
  56020. }
  56021. public function setProcessIsolation($processIsolation)
  56022. {
  56023. $this->processIsolation = (bool) $processIsolation;
  56024. if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) {
  56025. throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.');
  56026. }
  56027. }
  56028. }
  56029. <?php
  56030. namespace Symfony\Component\Console\Style;
  56031. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  56032. use Symfony\Component\Console\Helper\ProgressBar;
  56033. use Symfony\Component\Console\Output\OutputInterface;
  56034. abstract class OutputStyle implements OutputInterface, StyleInterface
  56035. {
  56036. private $output;
  56037. public function __construct(OutputInterface $output)
  56038. {
  56039. $this->output = $output;
  56040. }
  56041. public function newLine($count = 1)
  56042. {
  56043. $this->output->write(str_repeat(PHP_EOL, $count));
  56044. }
  56045. public function createProgressBar($max = 0)
  56046. {
  56047. return new ProgressBar($this->output, $max);
  56048. }
  56049. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  56050. {
  56051. $this->output->write($messages, $newline, $type);
  56052. }
  56053. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  56054. {
  56055. $this->output->writeln($messages, $type);
  56056. }
  56057. public function setVerbosity($level)
  56058. {
  56059. $this->output->setVerbosity($level);
  56060. }
  56061. public function getVerbosity()
  56062. {
  56063. return $this->output->getVerbosity();
  56064. }
  56065. public function setDecorated($decorated)
  56066. {
  56067. $this->output->setDecorated($decorated);
  56068. }
  56069. public function isDecorated()
  56070. {
  56071. return $this->output->isDecorated();
  56072. }
  56073. public function setFormatter(OutputFormatterInterface $formatter)
  56074. {
  56075. $this->output->setFormatter($formatter);
  56076. }
  56077. public function getFormatter()
  56078. {
  56079. return $this->output->getFormatter();
  56080. }
  56081. }
  56082. <?php
  56083. namespace Symfony\Component\Console\Style;
  56084. interface StyleInterface
  56085. {
  56086. public function title($message);
  56087. public function section($message);
  56088. public function listing(array $elements);
  56089. public function text($message);
  56090. public function success($message);
  56091. public function error($message);
  56092. public function warning($message);
  56093. public function note($message);
  56094. public function caution($message);
  56095. public function table(array $headers, array $rows);
  56096. public function ask($question, $default = null, $validator = null);
  56097. public function askHidden($question, $validator = null);
  56098. public function confirm($question, $default = true);
  56099. public function choice($question, array $choices, $default = null);
  56100. public function newLine($count = 1);
  56101. public function progressStart($max = 0);
  56102. public function progressAdvance($step = 1);
  56103. public function progressFinish();
  56104. }
  56105. <?php
  56106. namespace Symfony\Component\Console\Style;
  56107. use Symfony\Component\Console\Application;
  56108. use Symfony\Component\Console\Exception\RuntimeException;
  56109. use Symfony\Component\Console\Formatter\OutputFormatter;
  56110. use Symfony\Component\Console\Helper\Helper;
  56111. use Symfony\Component\Console\Helper\ProgressBar;
  56112. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  56113. use Symfony\Component\Console\Helper\Table;
  56114. use Symfony\Component\Console\Input\InputInterface;
  56115. use Symfony\Component\Console\Output\BufferedOutput;
  56116. use Symfony\Component\Console\Output\OutputInterface;
  56117. use Symfony\Component\Console\Question\ChoiceQuestion;
  56118. use Symfony\Component\Console\Question\ConfirmationQuestion;
  56119. use Symfony\Component\Console\Question\Question;
  56120. class SymfonyStyle extends OutputStyle
  56121. {
  56122. const MAX_LINE_LENGTH = 120;
  56123. private $input;
  56124. private $questionHelper;
  56125. private $progressBar;
  56126. private $lineLength;
  56127. private $bufferedOutput;
  56128. public function __construct(InputInterface $input, OutputInterface $output)
  56129. {
  56130. $this->input = $input;
  56131. $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
  56132. $this->lineLength = min($this->getTerminalWidth() - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  56133. parent::__construct($output);
  56134. }
  56135. public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
  56136. {
  56137. $messages = \is_array($messages) ? array_values($messages) : array($messages);
  56138. $this->autoPrependBlock();
  56139. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, true));
  56140. $this->newLine();
  56141. }
  56142. public function title($message)
  56143. {
  56144. $this->autoPrependBlock();
  56145. $this->writeln(array(
  56146. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  56147. sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  56148. ));
  56149. $this->newLine();
  56150. }
  56151. public function section($message)
  56152. {
  56153. $this->autoPrependBlock();
  56154. $this->writeln(array(
  56155. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  56156. sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  56157. ));
  56158. $this->newLine();
  56159. }
  56160. public function listing(array $elements)
  56161. {
  56162. $this->autoPrependText();
  56163. $elements = array_map(function ($element) {
  56164. return sprintf(' * %s', $element);
  56165. }, $elements);
  56166. $this->writeln($elements);
  56167. $this->newLine();
  56168. }
  56169. public function text($message)
  56170. {
  56171. $this->autoPrependText();
  56172. $messages = \is_array($message) ? array_values($message) : array($message);
  56173. foreach ($messages as $message) {
  56174. $this->writeln(sprintf(' %s', $message));
  56175. }
  56176. }
  56177. public function comment($message)
  56178. {
  56179. $messages = \is_array($message) ? array_values($message) : array($message);
  56180. $this->autoPrependBlock();
  56181. $this->writeln($this->createBlock($messages, null, null, '<fg=default;bg=default> // </>'));
  56182. $this->newLine();
  56183. }
  56184. public function success($message)
  56185. {
  56186. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  56187. }
  56188. public function error($message)
  56189. {
  56190. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  56191. }
  56192. public function warning($message)
  56193. {
  56194. $this->block($message, 'WARNING', 'fg=white;bg=red', ' ', true);
  56195. }
  56196. public function note($message)
  56197. {
  56198. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  56199. }
  56200. public function caution($message)
  56201. {
  56202. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  56203. }
  56204. public function table(array $headers, array $rows)
  56205. {
  56206. $style = clone Table::getStyleDefinition('symfony-style-guide');
  56207. $style->setCellHeaderFormat('<info>%s</info>');
  56208. $table = new Table($this);
  56209. $table->setHeaders($headers);
  56210. $table->setRows($rows);
  56211. $table->setStyle($style);
  56212. $table->render();
  56213. $this->newLine();
  56214. }
  56215. public function ask($question, $default = null, $validator = null)
  56216. {
  56217. $question = new Question($question, $default);
  56218. $question->setValidator($validator);
  56219. return $this->askQuestion($question);
  56220. }
  56221. public function askHidden($question, $validator = null)
  56222. {
  56223. $question = new Question($question);
  56224. $question->setHidden(true);
  56225. $question->setValidator($validator);
  56226. return $this->askQuestion($question);
  56227. }
  56228. public function confirm($question, $default = true)
  56229. {
  56230. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  56231. }
  56232. public function choice($question, array $choices, $default = null)
  56233. {
  56234. if (null !== $default) {
  56235. $values = array_flip($choices);
  56236. $default = $values[$default];
  56237. }
  56238. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  56239. }
  56240. public function progressStart($max = 0)
  56241. {
  56242. $this->progressBar = $this->createProgressBar($max);
  56243. $this->progressBar->start();
  56244. }
  56245. public function progressAdvance($step = 1)
  56246. {
  56247. $this->getProgressBar()->advance($step);
  56248. }
  56249. public function progressFinish()
  56250. {
  56251. $this->getProgressBar()->finish();
  56252. $this->newLine(2);
  56253. $this->progressBar = null;
  56254. }
  56255. public function createProgressBar($max = 0)
  56256. {
  56257. $progressBar = parent::createProgressBar($max);
  56258. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  56259. $progressBar->setEmptyBarCharacter('â–‘');
  56260. $progressBar->setProgressCharacter('');
  56261. $progressBar->setBarCharacter('â–“');
  56262. }
  56263. return $progressBar;
  56264. }
  56265. public function askQuestion(Question $question)
  56266. {
  56267. if ($this->input->isInteractive()) {
  56268. $this->autoPrependBlock();
  56269. }
  56270. if (!$this->questionHelper) {
  56271. $this->questionHelper = new SymfonyQuestionHelper();
  56272. }
  56273. $answer = $this->questionHelper->ask($this->input, $this, $question);
  56274. if ($this->input->isInteractive()) {
  56275. $this->newLine();
  56276. $this->bufferedOutput->write("\n");
  56277. }
  56278. return $answer;
  56279. }
  56280. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  56281. {
  56282. parent::writeln($messages, $type);
  56283. $this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
  56284. }
  56285. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  56286. {
  56287. parent::write($messages, $newline, $type);
  56288. $this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
  56289. }
  56290. public function newLine($count = 1)
  56291. {
  56292. parent::newLine($count);
  56293. $this->bufferedOutput->write(str_repeat("\n", $count));
  56294. }
  56295. private function getProgressBar()
  56296. {
  56297. if (!$this->progressBar) {
  56298. throw new RuntimeException('The ProgressBar is not started.');
  56299. }
  56300. return $this->progressBar;
  56301. }
  56302. private function getTerminalWidth()
  56303. {
  56304. $application = new Application();
  56305. $dimensions = $application->getTerminalDimensions();
  56306. return $dimensions[0] ?: self::MAX_LINE_LENGTH;
  56307. }
  56308. private function autoPrependBlock()
  56309. {
  56310. $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  56311. if (!isset($chars[0])) {
  56312. return $this->newLine();
  56313. }
  56314. $this->newLine(2 - substr_count($chars, "\n"));
  56315. }
  56316. private function autoPrependText()
  56317. {
  56318. $fetched = $this->bufferedOutput->fetch();
  56319. if ("\n" !== substr($fetched, -1)) {
  56320. $this->newLine();
  56321. }
  56322. }
  56323. private function reduceBuffer($messages)
  56324. {
  56325. return array_map(function ($value) {
  56326. return substr($value, -4);
  56327. }, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
  56328. }
  56329. private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
  56330. {
  56331. $indentLength = 0;
  56332. $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
  56333. $lines = array();
  56334. if (null !== $type) {
  56335. $type = sprintf('[%s] ', $type);
  56336. $indentLength = \strlen($type);
  56337. $lineIndentation = str_repeat(' ', $indentLength);
  56338. }
  56339. foreach ($messages as $key => $message) {
  56340. if ($escape) {
  56341. $message = OutputFormatter::escape($message);
  56342. }
  56343. $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
  56344. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  56345. $lines[] = '';
  56346. }
  56347. }
  56348. $firstLineIndex = 0;
  56349. if ($padding && $this->isDecorated()) {
  56350. $firstLineIndex = 1;
  56351. array_unshift($lines, '');
  56352. $lines[] = '';
  56353. }
  56354. foreach ($lines as $i => &$line) {
  56355. if (null !== $type) {
  56356. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  56357. }
  56358. $line = $prefix.$line;
  56359. $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
  56360. if ($style) {
  56361. $line = sprintf('<%s>%s</>', $style, $line);
  56362. }
  56363. }
  56364. return $lines;
  56365. }
  56366. }
  56367. <?php
  56368. namespace Symfony\Component\Console\Tester;
  56369. use Symfony\Component\Console\Application;
  56370. use Symfony\Component\Console\Input\ArrayInput;
  56371. use Symfony\Component\Console\Input\InputInterface;
  56372. use Symfony\Component\Console\Output\OutputInterface;
  56373. use Symfony\Component\Console\Output\StreamOutput;
  56374. class ApplicationTester
  56375. {
  56376. private $application;
  56377. private $input;
  56378. private $output;
  56379. private $statusCode;
  56380. public function __construct(Application $application)
  56381. {
  56382. $this->application = $application;
  56383. }
  56384. public function run(array $input, $options = array())
  56385. {
  56386. $this->input = new ArrayInput($input);
  56387. if (isset($options['interactive'])) {
  56388. $this->input->setInteractive($options['interactive']);
  56389. }
  56390. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  56391. if (isset($options['decorated'])) {
  56392. $this->output->setDecorated($options['decorated']);
  56393. }
  56394. if (isset($options['verbosity'])) {
  56395. $this->output->setVerbosity($options['verbosity']);
  56396. }
  56397. return $this->statusCode = $this->application->run($this->input, $this->output);
  56398. }
  56399. public function getDisplay($normalize = false)
  56400. {
  56401. rewind($this->output->getStream());
  56402. $display = stream_get_contents($this->output->getStream());
  56403. if ($normalize) {
  56404. $display = str_replace(PHP_EOL, "\n", $display);
  56405. }
  56406. return $display;
  56407. }
  56408. public function getInput()
  56409. {
  56410. return $this->input;
  56411. }
  56412. public function getOutput()
  56413. {
  56414. return $this->output;
  56415. }
  56416. public function getStatusCode()
  56417. {
  56418. return $this->statusCode;
  56419. }
  56420. }
  56421. <?php
  56422. namespace Symfony\Component\Console\Tester;
  56423. use Symfony\Component\Console\Command\Command;
  56424. use Symfony\Component\Console\Input\ArrayInput;
  56425. use Symfony\Component\Console\Input\InputInterface;
  56426. use Symfony\Component\Console\Output\OutputInterface;
  56427. use Symfony\Component\Console\Output\StreamOutput;
  56428. class CommandTester
  56429. {
  56430. private $command;
  56431. private $input;
  56432. private $output;
  56433. private $statusCode;
  56434. public function __construct(Command $command)
  56435. {
  56436. $this->command = $command;
  56437. }
  56438. public function execute(array $input, array $options = array())
  56439. {
  56440. if (!isset($input['command'])
  56441. && (null !== $application = $this->command->getApplication())
  56442. && $application->getDefinition()->hasArgument('command')
  56443. ) {
  56444. $input = array_merge(array('command' => $this->command->getName()), $input);
  56445. }
  56446. $this->input = new ArrayInput($input);
  56447. if (isset($options['interactive'])) {
  56448. $this->input->setInteractive($options['interactive']);
  56449. }
  56450. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  56451. $this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
  56452. if (isset($options['verbosity'])) {
  56453. $this->output->setVerbosity($options['verbosity']);
  56454. }
  56455. return $this->statusCode = $this->command->run($this->input, $this->output);
  56456. }
  56457. public function getDisplay($normalize = false)
  56458. {
  56459. rewind($this->output->getStream());
  56460. $display = stream_get_contents($this->output->getStream());
  56461. if ($normalize) {
  56462. $display = str_replace(PHP_EOL, "\n", $display);
  56463. }
  56464. return $display;
  56465. }
  56466. public function getInput()
  56467. {
  56468. return $this->input;
  56469. }
  56470. public function getOutput()
  56471. {
  56472. return $this->output;
  56473. }
  56474. public function getStatusCode()
  56475. {
  56476. return $this->statusCode;
  56477. }
  56478. }
  56479. <?php
  56480. namespace Symfony\Component\Debug;
  56481. use Psr\Log\AbstractLogger;
  56482. class BufferingLogger extends AbstractLogger
  56483. {
  56484. private $logs = array();
  56485. public function log($level, $message, array $context = array())
  56486. {
  56487. $this->logs[] = array($level, $message, $context);
  56488. }
  56489. public function cleanLogs()
  56490. {
  56491. $logs = $this->logs;
  56492. $this->logs = array();
  56493. return $logs;
  56494. }
  56495. }
  56496. <?php
  56497. namespace Symfony\Component\Debug;
  56498. class Debug
  56499. {
  56500. private static $enabled = false;
  56501. public static function enable($errorReportingLevel = null, $displayErrors = true)
  56502. {
  56503. if (static::$enabled) {
  56504. return;
  56505. }
  56506. static::$enabled = true;
  56507. if (null !== $errorReportingLevel) {
  56508. error_reporting($errorReportingLevel);
  56509. } else {
  56510. error_reporting(-1);
  56511. }
  56512. if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
  56513. ini_set('display_errors', 0);
  56514. ExceptionHandler::register();
  56515. } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  56516. ini_set('display_errors', 1);
  56517. }
  56518. if ($displayErrors) {
  56519. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  56520. } else {
  56521. ErrorHandler::register()->throwAt(0, true);
  56522. }
  56523. DebugClassLoader::enable();
  56524. }
  56525. }
  56526. <?php
  56527. namespace Symfony\Component\Debug;
  56528. class DebugClassLoader
  56529. {
  56530. private $classLoader;
  56531. private $isFinder;
  56532. private $loaded = array();
  56533. private $wasFinder;
  56534. private static $caseCheck;
  56535. private static $deprecated = array();
  56536. private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
  56537. private static $darwinCache = array('/' => array('/', array()));
  56538. public function __construct($classLoader)
  56539. {
  56540. $this->wasFinder = \is_object($classLoader) && method_exists($classLoader, 'findFile');
  56541. if ($this->wasFinder) {
  56542. @trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
  56543. $this->classLoader = array($classLoader, 'loadClass');
  56544. $this->isFinder = true;
  56545. } else {
  56546. $this->classLoader = $classLoader;
  56547. $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
  56548. }
  56549. if (!isset(self::$caseCheck)) {
  56550. $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
  56551. $i = strrpos($file, \DIRECTORY_SEPARATOR);
  56552. $dir = substr($file, 0, 1 + $i);
  56553. $file = substr($file, 1 + $i);
  56554. $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
  56555. $test = realpath($dir.$test);
  56556. if (false === $test || false === $i) {
  56557. self::$caseCheck = 0;
  56558. } elseif (substr($test, -\strlen($file)) === $file) {
  56559. self::$caseCheck = 1;
  56560. } elseif (false !== stripos(PHP_OS, 'darwin')) {
  56561. self::$caseCheck = 2;
  56562. } else {
  56563. self::$caseCheck = 0;
  56564. }
  56565. }
  56566. }
  56567. public function getClassLoader()
  56568. {
  56569. return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
  56570. }
  56571. public static function enable()
  56572. {
  56573. class_exists('Symfony\Component\Debug\ErrorHandler');
  56574. class_exists('Psr\Log\LogLevel');
  56575. if (!\is_array($functions = spl_autoload_functions())) {
  56576. return;
  56577. }
  56578. foreach ($functions as $function) {
  56579. spl_autoload_unregister($function);
  56580. }
  56581. foreach ($functions as $function) {
  56582. if (!\is_array($function) || !$function[0] instanceof self) {
  56583. $function = array(new static($function), 'loadClass');
  56584. }
  56585. spl_autoload_register($function);
  56586. }
  56587. }
  56588. public static function disable()
  56589. {
  56590. if (!\is_array($functions = spl_autoload_functions())) {
  56591. return;
  56592. }
  56593. foreach ($functions as $function) {
  56594. spl_autoload_unregister($function);
  56595. }
  56596. foreach ($functions as $function) {
  56597. if (\is_array($function) && $function[0] instanceof self) {
  56598. $function = $function[0]->getClassLoader();
  56599. }
  56600. spl_autoload_register($function);
  56601. }
  56602. }
  56603. public function findFile($class)
  56604. {
  56605. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  56606. if ($this->wasFinder) {
  56607. return $this->classLoader[0]->findFile($class);
  56608. }
  56609. }
  56610. public function loadClass($class)
  56611. {
  56612. ErrorHandler::stackErrors();
  56613. try {
  56614. if ($this->isFinder && !isset($this->loaded[$class])) {
  56615. $this->loaded[$class] = true;
  56616. if ($file = $this->classLoader[0]->findFile($class)) {
  56617. require $file;
  56618. }
  56619. } else {
  56620. \call_user_func($this->classLoader, $class);
  56621. $file = false;
  56622. }
  56623. } catch (\Exception $e) {
  56624. ErrorHandler::unstackErrors();
  56625. throw $e;
  56626. } catch (\Throwable $e) {
  56627. ErrorHandler::unstackErrors();
  56628. throw $e;
  56629. }
  56630. ErrorHandler::unstackErrors();
  56631. $exists = class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  56632. if ($class && '\\' === $class[0]) {
  56633. $class = substr($class, 1);
  56634. }
  56635. if ($exists) {
  56636. $refl = new \ReflectionClass($class);
  56637. $name = $refl->getName();
  56638. if ($name !== $class && 0 === strcasecmp($name, $class)) {
  56639. throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
  56640. }
  56641. if (\in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
  56642. @trigger_error(sprintf('%s uses a reserved class name (%s) that will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
  56643. } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
  56644. self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
  56645. } else {
  56646. if (2 > $len = 1 + (strpos($name, '\\') ?: strpos($name, '_'))) {
  56647. $len = 0;
  56648. $ns = '';
  56649. } else {
  56650. $ns = substr($name, 0, $len);
  56651. }
  56652. $parent = get_parent_class($class);
  56653. if (!$parent || strncmp($ns, $parent, $len)) {
  56654. if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
  56655. @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
  56656. }
  56657. $parentInterfaces = array();
  56658. $deprecatedInterfaces = array();
  56659. if ($parent) {
  56660. foreach (class_implements($parent) as $interface) {
  56661. $parentInterfaces[$interface] = 1;
  56662. }
  56663. }
  56664. foreach ($refl->getInterfaceNames() as $interface) {
  56665. if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
  56666. $deprecatedInterfaces[] = $interface;
  56667. }
  56668. foreach (class_implements($interface) as $interface) {
  56669. $parentInterfaces[$interface] = 1;
  56670. }
  56671. }
  56672. foreach ($deprecatedInterfaces as $interface) {
  56673. if (!isset($parentInterfaces[$interface])) {
  56674. @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);
  56675. }
  56676. }
  56677. }
  56678. }
  56679. }
  56680. if ($file) {
  56681. if (!$exists) {
  56682. if (false !== strpos($class, '/')) {
  56683. 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));
  56684. }
  56685. 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));
  56686. }
  56687. if (self::$caseCheck) {
  56688. $real = explode('\\', $class.strrchr($file, '.'));
  56689. $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file));
  56690. $i = \count($tail) - 1;
  56691. $j = \count($real) - 1;
  56692. while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
  56693. --$i;
  56694. --$j;
  56695. }
  56696. array_splice($tail, 0, $i + 1);
  56697. }
  56698. if (self::$caseCheck && $tail) {
  56699. $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
  56700. $tailLen = \strlen($tail);
  56701. $real = $refl->getFileName();
  56702. if (2 === self::$caseCheck) {
  56703. $i = 1 + strrpos($real, '/');
  56704. $file = substr($real, $i);
  56705. $real = substr($real, 0, $i);
  56706. if (isset(self::$darwinCache[$real])) {
  56707. $kDir = $real;
  56708. } else {
  56709. $kDir = strtolower($real);
  56710. if (isset(self::$darwinCache[$kDir])) {
  56711. $real = self::$darwinCache[$kDir][0];
  56712. } else {
  56713. $dir = getcwd();
  56714. chdir($real);
  56715. $real = getcwd().'/';
  56716. chdir($dir);
  56717. $dir = $real;
  56718. $k = $kDir;
  56719. $i = \strlen($dir) - 1;
  56720. while (!isset(self::$darwinCache[$k])) {
  56721. self::$darwinCache[$k] = array($dir, array());
  56722. self::$darwinCache[$dir] = &self::$darwinCache[$k];
  56723. while ('/' !== $dir[--$i]) {
  56724. }
  56725. $k = substr($k, 0, ++$i);
  56726. $dir = substr($dir, 0, $i--);
  56727. }
  56728. }
  56729. }
  56730. $dirFiles = self::$darwinCache[$kDir][1];
  56731. if (isset($dirFiles[$file])) {
  56732. $kFile = $file;
  56733. } else {
  56734. $kFile = strtolower($file);
  56735. if (!isset($dirFiles[$kFile])) {
  56736. foreach (scandir($real, 2) as $f) {
  56737. if ('.' !== $f[0]) {
  56738. $dirFiles[$f] = $f;
  56739. if ($f === $file) {
  56740. $kFile = $k = $file;
  56741. } elseif ($f !== $k = strtolower($f)) {
  56742. $dirFiles[$k] = $f;
  56743. }
  56744. }
  56745. }
  56746. self::$darwinCache[$kDir][1] = $dirFiles;
  56747. }
  56748. }
  56749. $real .= $dirFiles[$kFile];
  56750. }
  56751. if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
  56752. && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
  56753. ) {
  56754. 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)));
  56755. }
  56756. }
  56757. return true;
  56758. }
  56759. }
  56760. }
  56761. <?php
  56762. namespace Symfony\Component\Debug;
  56763. use Psr\Log\LoggerInterface;
  56764. use Psr\Log\LogLevel;
  56765. use Symfony\Component\Debug\Exception\ContextErrorException;
  56766. use Symfony\Component\Debug\Exception\FatalErrorException;
  56767. use Symfony\Component\Debug\Exception\FatalThrowableError;
  56768. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  56769. use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
  56770. use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
  56771. use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
  56772. use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
  56773. class ErrorHandler
  56774. {
  56775. const TYPE_DEPRECATION = -100;
  56776. private $levels = array(
  56777. E_DEPRECATED => 'Deprecated',
  56778. E_USER_DEPRECATED => 'User Deprecated',
  56779. E_NOTICE => 'Notice',
  56780. E_USER_NOTICE => 'User Notice',
  56781. E_STRICT => 'Runtime Notice',
  56782. E_WARNING => 'Warning',
  56783. E_USER_WARNING => 'User Warning',
  56784. E_COMPILE_WARNING => 'Compile Warning',
  56785. E_CORE_WARNING => 'Core Warning',
  56786. E_USER_ERROR => 'User Error',
  56787. E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
  56788. E_COMPILE_ERROR => 'Compile Error',
  56789. E_PARSE => 'Parse Error',
  56790. E_ERROR => 'Error',
  56791. E_CORE_ERROR => 'Core Error',
  56792. );
  56793. private $loggers = array(
  56794. E_DEPRECATED => array(null, LogLevel::INFO),
  56795. E_USER_DEPRECATED => array(null, LogLevel::INFO),
  56796. E_NOTICE => array(null, LogLevel::WARNING),
  56797. E_USER_NOTICE => array(null, LogLevel::WARNING),
  56798. E_STRICT => array(null, LogLevel::WARNING),
  56799. E_WARNING => array(null, LogLevel::WARNING),
  56800. E_USER_WARNING => array(null, LogLevel::WARNING),
  56801. E_COMPILE_WARNING => array(null, LogLevel::WARNING),
  56802. E_CORE_WARNING => array(null, LogLevel::WARNING),
  56803. E_USER_ERROR => array(null, LogLevel::CRITICAL),
  56804. E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL),
  56805. E_COMPILE_ERROR => array(null, LogLevel::CRITICAL),
  56806. E_PARSE => array(null, LogLevel::CRITICAL),
  56807. E_ERROR => array(null, LogLevel::CRITICAL),
  56808. E_CORE_ERROR => array(null, LogLevel::CRITICAL),
  56809. );
  56810. private $thrownErrors = 0x1FFF;
  56811. private $scopedErrors = 0x1FFF;
  56812. private $tracedErrors = 0x77FB;
  56813. private $screamedErrors = 0x55;
  56814. private $loggedErrors = 0;
  56815. private $loggedTraces = array();
  56816. private $isRecursive = 0;
  56817. private $isRoot = false;
  56818. private $exceptionHandler;
  56819. private $bootstrappingLogger;
  56820. private static $reservedMemory;
  56821. private static $stackedErrors = array();
  56822. private static $stackedErrorLevels = array();
  56823. private static $toStringException = null;
  56824. private static $exitCode = 0;
  56825. private $displayErrors = 0x1FFF;
  56826. public static function register($handler = null, $replace = true)
  56827. {
  56828. if (null === self::$reservedMemory) {
  56829. self::$reservedMemory = str_repeat('x', 10240);
  56830. register_shutdown_function(__CLASS__.'::handleFatalError');
  56831. }
  56832. $levels = -1;
  56833. if ($handlerIsNew = !$handler instanceof self) {
  56834. if (null !== $handler) {
  56835. $levels = $replace ? $handler : 0;
  56836. $replace = true;
  56837. }
  56838. $handler = new static();
  56839. }
  56840. if (null === $prev = set_error_handler(array($handler, 'handleError'))) {
  56841. restore_error_handler();
  56842. set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
  56843. $handler->isRoot = true;
  56844. }
  56845. if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
  56846. $handler = $prev[0];
  56847. $replace = false;
  56848. }
  56849. if (!$replace && $prev) {
  56850. restore_error_handler();
  56851. $handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
  56852. } else {
  56853. $handlerIsRegistered = true;
  56854. }
  56855. if (\is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) {
  56856. restore_exception_handler();
  56857. if (!$handlerIsRegistered) {
  56858. $handler = $prev[0];
  56859. } elseif ($handler !== $prev[0] && $replace) {
  56860. set_exception_handler(array($handler, 'handleException'));
  56861. $p = $prev[0]->setExceptionHandler(null);
  56862. $handler->setExceptionHandler($p);
  56863. $prev[0]->setExceptionHandler($p);
  56864. }
  56865. } else {
  56866. $handler->setExceptionHandler($prev);
  56867. }
  56868. $handler->throwAt($levels & $handler->thrownErrors, true);
  56869. return $handler;
  56870. }
  56871. public function __construct(BufferingLogger $bootstrappingLogger = null)
  56872. {
  56873. if ($bootstrappingLogger) {
  56874. $this->bootstrappingLogger = $bootstrappingLogger;
  56875. $this->setDefaultLogger($bootstrappingLogger);
  56876. }
  56877. }
  56878. public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
  56879. {
  56880. $loggers = array();
  56881. if (\is_array($levels)) {
  56882. foreach ($levels as $type => $logLevel) {
  56883. if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
  56884. $loggers[$type] = array($logger, $logLevel);
  56885. }
  56886. }
  56887. } else {
  56888. if (null === $levels) {
  56889. $levels = E_ALL | E_STRICT;
  56890. }
  56891. foreach ($this->loggers as $type => $log) {
  56892. if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
  56893. $log[0] = $logger;
  56894. $loggers[$type] = $log;
  56895. }
  56896. }
  56897. }
  56898. $this->setLoggers($loggers);
  56899. }
  56900. public function setLoggers(array $loggers)
  56901. {
  56902. $prevLogged = $this->loggedErrors;
  56903. $prev = $this->loggers;
  56904. $flush = array();
  56905. foreach ($loggers as $type => $log) {
  56906. if (!isset($prev[$type])) {
  56907. throw new \InvalidArgumentException('Unknown error type: '.$type);
  56908. }
  56909. if (!\is_array($log)) {
  56910. $log = array($log);
  56911. } elseif (!array_key_exists(0, $log)) {
  56912. throw new \InvalidArgumentException('No logger provided');
  56913. }
  56914. if (null === $log[0]) {
  56915. $this->loggedErrors &= ~$type;
  56916. } elseif ($log[0] instanceof LoggerInterface) {
  56917. $this->loggedErrors |= $type;
  56918. } else {
  56919. throw new \InvalidArgumentException('Invalid logger provided');
  56920. }
  56921. $this->loggers[$type] = $log + $prev[$type];
  56922. if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
  56923. $flush[$type] = $type;
  56924. }
  56925. }
  56926. $this->reRegister($prevLogged | $this->thrownErrors);
  56927. if ($flush) {
  56928. foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
  56929. $type = $log[2]['type'];
  56930. if (!isset($flush[$type])) {
  56931. $this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
  56932. } elseif ($this->loggers[$type][0]) {
  56933. $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
  56934. }
  56935. }
  56936. }
  56937. return $prev;
  56938. }
  56939. public function setExceptionHandler($handler)
  56940. {
  56941. if (null !== $handler && !\is_callable($handler)) {
  56942. throw new \LogicException('The exception handler must be a valid PHP callable.');
  56943. }
  56944. $prev = $this->exceptionHandler;
  56945. $this->exceptionHandler = $handler;
  56946. return $prev;
  56947. }
  56948. public function throwAt($levels, $replace = false)
  56949. {
  56950. $prev = $this->thrownErrors;
  56951. $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
  56952. if (!$replace) {
  56953. $this->thrownErrors |= $prev;
  56954. }
  56955. $this->reRegister($prev | $this->loggedErrors);
  56956. $this->displayErrors = $this->thrownErrors;
  56957. return $prev;
  56958. }
  56959. public function scopeAt($levels, $replace = false)
  56960. {
  56961. $prev = $this->scopedErrors;
  56962. $this->scopedErrors = (int) $levels;
  56963. if (!$replace) {
  56964. $this->scopedErrors |= $prev;
  56965. }
  56966. return $prev;
  56967. }
  56968. public function traceAt($levels, $replace = false)
  56969. {
  56970. $prev = $this->tracedErrors;
  56971. $this->tracedErrors = (int) $levels;
  56972. if (!$replace) {
  56973. $this->tracedErrors |= $prev;
  56974. }
  56975. return $prev;
  56976. }
  56977. public function screamAt($levels, $replace = false)
  56978. {
  56979. $prev = $this->screamedErrors;
  56980. $this->screamedErrors = (int) $levels;
  56981. if (!$replace) {
  56982. $this->screamedErrors |= $prev;
  56983. }
  56984. return $prev;
  56985. }
  56986. private function reRegister($prev)
  56987. {
  56988. if ($prev !== $this->thrownErrors | $this->loggedErrors) {
  56989. $handler = set_error_handler('var_dump');
  56990. $handler = \is_array($handler) ? $handler[0] : null;
  56991. restore_error_handler();
  56992. if ($handler === $this) {
  56993. restore_error_handler();
  56994. if ($this->isRoot) {
  56995. set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
  56996. } else {
  56997. set_error_handler(array($this, 'handleError'));
  56998. }
  56999. }
  57000. }
  57001. }
  57002. public function handleError($type, $message, $file, $line)
  57003. {
  57004. $level = error_reporting();
  57005. $silenced = 0 === ($level & $type);
  57006. $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
  57007. $log = $this->loggedErrors & $type;
  57008. $throw = $this->thrownErrors & $type & $level;
  57009. $type &= $level | $this->screamedErrors;
  57010. if (!$type || (!$log && !$throw)) {
  57011. return !$silenced && $type && $log;
  57012. }
  57013. $scope = $this->scopedErrors & $type;
  57014. if (4 < $numArgs = \func_num_args()) {
  57015. $context = $scope ? (func_get_arg(4) ?: array()) : array();
  57016. $backtrace = 5 < $numArgs ? func_get_arg(5) : null;
  57017. } else {
  57018. $context = array();
  57019. $backtrace = null;
  57020. }
  57021. if (isset($context['GLOBALS']) && $scope) {
  57022. $e = $context;
  57023. unset($e['GLOBALS'], $context);
  57024. $context = $e;
  57025. }
  57026. if (null !== $backtrace && $type & E_ERROR) {
  57027. $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
  57028. return true;
  57029. }
  57030. if ($throw) {
  57031. if (null !== self::$toStringException) {
  57032. $throw = self::$toStringException;
  57033. self::$toStringException = null;
  57034. } elseif ($scope && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
  57035. $throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
  57036. } else {
  57037. $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
  57038. }
  57039. if (\PHP_VERSION_ID <= 50407 && (\PHP_VERSION_ID >= 50400 || \PHP_VERSION_ID <= 50317)) {
  57040. $throw->errorHandlerCanary = new ErrorHandlerCanary();
  57041. }
  57042. if (E_USER_ERROR & $type) {
  57043. $backtrace = $backtrace ?: $throw->getTrace();
  57044. for ($i = 1; isset($backtrace[$i]); ++$i) {
  57045. if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
  57046. && '__toString' === $backtrace[$i]['function']
  57047. && '->' === $backtrace[$i]['type']
  57048. && !isset($backtrace[$i - 1]['class'])
  57049. && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
  57050. ) {
  57051. foreach ($context as $e) {
  57052. if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
  57053. if (1 === $i) {
  57054. $throw = $e;
  57055. break;
  57056. }
  57057. self::$toStringException = $e;
  57058. return true;
  57059. }
  57060. }
  57061. if (1 < $i) {
  57062. $this->handleException($throw);
  57063. return false;
  57064. }
  57065. }
  57066. }
  57067. }
  57068. throw $throw;
  57069. }
  57070. $e = md5("{$type}/{$line}/{$file}\x00{$message}", true);
  57071. $trace = true;
  57072. if (!($this->tracedErrors & $type) || isset($this->loggedTraces[$e])) {
  57073. $trace = false;
  57074. } else {
  57075. $this->loggedTraces[$e] = 1;
  57076. }
  57077. $e = compact('type', 'file', 'line', 'level');
  57078. if ($type & $level) {
  57079. if ($scope) {
  57080. $e['scope_vars'] = $context;
  57081. if ($trace) {
  57082. $e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
  57083. }
  57084. } elseif ($trace) {
  57085. if (null === $backtrace) {
  57086. $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  57087. } else {
  57088. foreach ($backtrace as &$frame) {
  57089. unset($frame['args'], $frame);
  57090. }
  57091. $e['stack'] = $backtrace;
  57092. }
  57093. }
  57094. }
  57095. if ($this->isRecursive) {
  57096. $log = 0;
  57097. } elseif (self::$stackedErrorLevels) {
  57098. self::$stackedErrors[] = array($this->loggers[$type][0], ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  57099. } else {
  57100. try {
  57101. $this->isRecursive = true;
  57102. $this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  57103. $this->isRecursive = false;
  57104. } catch (\Exception $e) {
  57105. $this->isRecursive = false;
  57106. throw $e;
  57107. } catch (\Throwable $e) {
  57108. $this->isRecursive = false;
  57109. throw $e;
  57110. }
  57111. }
  57112. return !$silenced && $type && $log;
  57113. }
  57114. public function handleException($exception, array $error = null)
  57115. {
  57116. if (null === $error) {
  57117. self::$exitCode = 255;
  57118. }
  57119. if (!$exception instanceof \Exception) {
  57120. $exception = new FatalThrowableError($exception);
  57121. }
  57122. $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
  57123. $handlerException = null;
  57124. if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
  57125. $e = array(
  57126. 'type' => $type,
  57127. 'file' => $exception->getFile(),
  57128. 'line' => $exception->getLine(),
  57129. 'level' => error_reporting(),
  57130. 'stack' => $exception->getTrace(),
  57131. );
  57132. if ($exception instanceof FatalErrorException) {
  57133. if ($exception instanceof FatalThrowableError) {
  57134. $error = array(
  57135. 'type' => $type,
  57136. 'message' => $message = $exception->getMessage(),
  57137. 'file' => $e['file'],
  57138. 'line' => $e['line'],
  57139. );
  57140. } else {
  57141. $message = 'Fatal '.$exception->getMessage();
  57142. }
  57143. } elseif ($exception instanceof \ErrorException) {
  57144. $message = 'Uncaught '.$exception->getMessage();
  57145. if ($exception instanceof ContextErrorException) {
  57146. $e['context'] = $exception->getContext();
  57147. }
  57148. } else {
  57149. $message = 'Uncaught Exception: '.$exception->getMessage();
  57150. }
  57151. }
  57152. if ($this->loggedErrors & $type) {
  57153. try {
  57154. $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
  57155. } catch (\Exception $handlerException) {
  57156. } catch (\Throwable $handlerException) {
  57157. }
  57158. }
  57159. if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
  57160. foreach ($this->getFatalErrorHandlers() as $handler) {
  57161. if ($e = $handler->handleError($error, $exception)) {
  57162. $exception = $e;
  57163. break;
  57164. }
  57165. }
  57166. }
  57167. $exceptionHandler = $this->exceptionHandler;
  57168. $this->exceptionHandler = null;
  57169. try {
  57170. if (null !== $exceptionHandler) {
  57171. return \call_user_func($exceptionHandler, $exception);
  57172. }
  57173. $handlerException = $handlerException ?: $exception;
  57174. } catch (\Exception $handlerException) {
  57175. } catch (\Throwable $handlerException) {
  57176. }
  57177. if ($exception === $handlerException) {
  57178. self::$reservedMemory = null;
  57179. throw $exception;
  57180. }
  57181. $this->handleException($handlerException);
  57182. }
  57183. public static function handleFatalError(array $error = null)
  57184. {
  57185. if (null === self::$reservedMemory) {
  57186. return;
  57187. }
  57188. $handler = self::$reservedMemory = null;
  57189. $handlers = array();
  57190. $previousHandler = null;
  57191. $sameHandlerLimit = 10;
  57192. while (!\is_array($handler) || !$handler[0] instanceof self) {
  57193. $handler = set_exception_handler('var_dump');
  57194. restore_exception_handler();
  57195. if (!$handler) {
  57196. break;
  57197. }
  57198. restore_exception_handler();
  57199. if ($handler !== $previousHandler) {
  57200. array_unshift($handlers, $handler);
  57201. $previousHandler = $handler;
  57202. } elseif (0 === --$sameHandlerLimit) {
  57203. $handler = null;
  57204. break;
  57205. }
  57206. }
  57207. foreach ($handlers as $h) {
  57208. set_exception_handler($h);
  57209. }
  57210. if (!$handler) {
  57211. return;
  57212. }
  57213. if ($handler !== $h) {
  57214. $handler[0]->setExceptionHandler($h);
  57215. }
  57216. $handler = $handler[0];
  57217. $handlers = array();
  57218. if ($exit = null === $error) {
  57219. $error = error_get_last();
  57220. }
  57221. try {
  57222. while (self::$stackedErrorLevels) {
  57223. static::unstackErrors();
  57224. }
  57225. } catch (\Exception $exception) {
  57226. } catch (\Throwable $exception) {
  57227. }
  57228. if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
  57229. $handler->throwAt(0, true);
  57230. $trace = isset($error['backtrace']) ? $error['backtrace'] : null;
  57231. if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
  57232. $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
  57233. } else {
  57234. $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
  57235. }
  57236. }
  57237. try {
  57238. if (isset($exception)) {
  57239. self::$exitCode = 255;
  57240. $handler->handleException($exception, $error);
  57241. }
  57242. } catch (FatalErrorException $e) {
  57243. }
  57244. if ($exit && self::$exitCode) {
  57245. $exitCode = self::$exitCode;
  57246. register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
  57247. }
  57248. }
  57249. public static function stackErrors()
  57250. {
  57251. self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  57252. }
  57253. public static function unstackErrors()
  57254. {
  57255. $level = array_pop(self::$stackedErrorLevels);
  57256. if (null !== $level) {
  57257. $e = error_reporting($level);
  57258. if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
  57259. error_reporting($e);
  57260. }
  57261. }
  57262. if (empty(self::$stackedErrorLevels)) {
  57263. $errors = self::$stackedErrors;
  57264. self::$stackedErrors = array();
  57265. foreach ($errors as $e) {
  57266. $e[0]->log($e[1], $e[2], $e[3]);
  57267. }
  57268. }
  57269. }
  57270. protected function getFatalErrorHandlers()
  57271. {
  57272. return array(
  57273. new UndefinedFunctionFatalErrorHandler(),
  57274. new UndefinedMethodFatalErrorHandler(),
  57275. new ClassNotFoundFatalErrorHandler(),
  57276. );
  57277. }
  57278. public function setLevel($level)
  57279. {
  57280. @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);
  57281. $level = null === $level ? error_reporting() : $level;
  57282. $this->throwAt($level, true);
  57283. }
  57284. public function setDisplayErrors($displayErrors)
  57285. {
  57286. @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);
  57287. if ($displayErrors) {
  57288. $this->throwAt($this->displayErrors, true);
  57289. } else {
  57290. $displayErrors = $this->displayErrors;
  57291. $this->throwAt(0, true);
  57292. $this->displayErrors = $displayErrors;
  57293. }
  57294. }
  57295. public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
  57296. {
  57297. @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);
  57298. $handler = set_error_handler('var_dump');
  57299. $handler = \is_array($handler) ? $handler[0] : null;
  57300. restore_error_handler();
  57301. if (!$handler instanceof self) {
  57302. return;
  57303. }
  57304. if ('deprecation' === $channel) {
  57305. $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
  57306. $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
  57307. } elseif ('scream' === $channel) {
  57308. $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
  57309. $handler->screamAt(E_ALL | E_STRICT);
  57310. } elseif ('emergency' === $channel) {
  57311. $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
  57312. $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  57313. }
  57314. }
  57315. public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
  57316. {
  57317. $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());
  57318. return $this->handleError($level, $message, $file, $line, (array) $context);
  57319. }
  57320. public function handleFatal()
  57321. {
  57322. @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);
  57323. static::handleFatalError();
  57324. }
  57325. }
  57326. class ErrorHandlerCanary
  57327. {
  57328. private static $displayErrors = null;
  57329. public function __construct()
  57330. {
  57331. if (null === self::$displayErrors) {
  57332. self::$displayErrors = ini_set('display_errors', 1);
  57333. }
  57334. }
  57335. public function __destruct()
  57336. {
  57337. if (null !== self::$displayErrors) {
  57338. ini_set('display_errors', self::$displayErrors);
  57339. self::$displayErrors = null;
  57340. }
  57341. }
  57342. }
  57343. <?php
  57344. namespace Symfony\Component\Debug\Exception;
  57345. class ClassNotFoundException extends FatalErrorException
  57346. {
  57347. public function __construct($message, \ErrorException $previous)
  57348. {
  57349. parent::__construct(
  57350. $message,
  57351. $previous->getCode(),
  57352. $previous->getSeverity(),
  57353. $previous->getFile(),
  57354. $previous->getLine(),
  57355. null,
  57356. true,
  57357. null,
  57358. $previous->getPrevious()
  57359. );
  57360. $this->setTrace($previous->getTrace());
  57361. }
  57362. }
  57363. <?php
  57364. namespace Symfony\Component\Debug\Exception;
  57365. class ContextErrorException extends \ErrorException
  57366. {
  57367. private $context = array();
  57368. public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
  57369. {
  57370. parent::__construct($message, $code, $severity, $filename, $lineno);
  57371. $this->context = $context;
  57372. }
  57373. public function getContext()
  57374. {
  57375. return $this->context;
  57376. }
  57377. }
  57378. <?php
  57379. namespace Symfony\Component\Debug\Exception;
  57380. @trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  57381. class DummyException extends \ErrorException
  57382. {
  57383. }
  57384. <?php
  57385. namespace Symfony\Component\HttpKernel\Exception;
  57386. class FatalErrorException extends \ErrorException
  57387. {
  57388. }
  57389. namespace Symfony\Component\Debug\Exception;
  57390. use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
  57391. class FatalErrorException extends LegacyFatalErrorException
  57392. {
  57393. public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
  57394. {
  57395. parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
  57396. if (null !== $trace) {
  57397. if (!$traceArgs) {
  57398. foreach ($trace as &$frame) {
  57399. unset($frame['args'], $frame['this'], $frame);
  57400. }
  57401. }
  57402. $this->setTrace($trace);
  57403. } elseif (null !== $traceOffset) {
  57404. if (\function_exists('xdebug_get_function_stack')) {
  57405. $trace = xdebug_get_function_stack();
  57406. if (0 < $traceOffset) {
  57407. array_splice($trace, -$traceOffset);
  57408. }
  57409. foreach ($trace as &$frame) {
  57410. if (!isset($frame['type'])) {
  57411. if (isset($frame['class'])) {
  57412. $frame['type'] = '::';
  57413. }
  57414. } elseif ('dynamic' === $frame['type']) {
  57415. $frame['type'] = '->';
  57416. } elseif ('static' === $frame['type']) {
  57417. $frame['type'] = '::';
  57418. }
  57419. if (!$traceArgs) {
  57420. unset($frame['params'], $frame['args']);
  57421. } elseif (isset($frame['params']) && !isset($frame['args'])) {
  57422. $frame['args'] = $frame['params'];
  57423. unset($frame['params']);
  57424. }
  57425. }
  57426. unset($frame);
  57427. $trace = array_reverse($trace);
  57428. } elseif (\function_exists('symfony_debug_backtrace')) {
  57429. $trace = symfony_debug_backtrace();
  57430. if (0 < $traceOffset) {
  57431. array_splice($trace, 0, $traceOffset);
  57432. }
  57433. } else {
  57434. $trace = array();
  57435. }
  57436. $this->setTrace($trace);
  57437. }
  57438. }
  57439. protected function setTrace($trace)
  57440. {
  57441. $traceReflector = new \ReflectionProperty('Exception', 'trace');
  57442. $traceReflector->setAccessible(true);
  57443. $traceReflector->setValue($this, $trace);
  57444. }
  57445. }
  57446. <?php
  57447. namespace Symfony\Component\Debug\Exception;
  57448. class FatalThrowableError extends FatalErrorException
  57449. {
  57450. public function __construct(\Throwable $e)
  57451. {
  57452. if ($e instanceof \ParseError) {
  57453. $message = 'Parse error: '.$e->getMessage();
  57454. $severity = E_PARSE;
  57455. } elseif ($e instanceof \TypeError) {
  57456. $message = 'Type error: '.$e->getMessage();
  57457. $severity = E_RECOVERABLE_ERROR;
  57458. } else {
  57459. $message = $e->getMessage();
  57460. $severity = E_ERROR;
  57461. }
  57462. \ErrorException::__construct(
  57463. $message,
  57464. $e->getCode(),
  57465. $severity,
  57466. $e->getFile(),
  57467. $e->getLine(),
  57468. $e->getPrevious()
  57469. );
  57470. $this->setTrace($e->getTrace());
  57471. }
  57472. }
  57473. <?php
  57474. namespace Symfony\Component\HttpKernel\Exception;
  57475. use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
  57476. class FlattenException
  57477. {
  57478. private $handler;
  57479. public static function __callStatic($method, $args)
  57480. {
  57481. if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
  57482. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_called_class(), $method));
  57483. }
  57484. return \call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
  57485. }
  57486. public function __call($method, $args)
  57487. {
  57488. if (!isset($this->handler)) {
  57489. $this->handler = new DebugFlattenException();
  57490. }
  57491. if (!method_exists($this->handler, $method)) {
  57492. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_class($this), $method));
  57493. }
  57494. return \call_user_func_array(array($this->handler, $method), $args);
  57495. }
  57496. }
  57497. namespace Symfony\Component\Debug\Exception;
  57498. use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
  57499. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  57500. class FlattenException extends LegacyFlattenException
  57501. {
  57502. private $message;
  57503. private $code;
  57504. private $previous;
  57505. private $trace;
  57506. private $class;
  57507. private $statusCode;
  57508. private $headers;
  57509. private $file;
  57510. private $line;
  57511. public static function create(\Exception $exception, $statusCode = null, array $headers = array())
  57512. {
  57513. $e = new static();
  57514. $e->setMessage($exception->getMessage());
  57515. $e->setCode($exception->getCode());
  57516. if ($exception instanceof HttpExceptionInterface) {
  57517. $statusCode = $exception->getStatusCode();
  57518. $headers = array_merge($headers, $exception->getHeaders());
  57519. }
  57520. if (null === $statusCode) {
  57521. $statusCode = 500;
  57522. }
  57523. $e->setStatusCode($statusCode);
  57524. $e->setHeaders($headers);
  57525. $e->setTraceFromException($exception);
  57526. $e->setClass(\get_class($exception));
  57527. $e->setFile($exception->getFile());
  57528. $e->setLine($exception->getLine());
  57529. $previous = $exception->getPrevious();
  57530. if ($previous instanceof \Exception) {
  57531. $e->setPrevious(static::create($previous));
  57532. } elseif ($previous instanceof \Throwable) {
  57533. $e->setPrevious(static::create(new FatalThrowableError($previous)));
  57534. }
  57535. return $e;
  57536. }
  57537. public function toArray()
  57538. {
  57539. $exceptions = array();
  57540. foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) {
  57541. $exceptions[] = array(
  57542. 'message' => $exception->getMessage(),
  57543. 'class' => $exception->getClass(),
  57544. 'trace' => $exception->getTrace(),
  57545. );
  57546. }
  57547. return $exceptions;
  57548. }
  57549. public function getStatusCode()
  57550. {
  57551. return $this->statusCode;
  57552. }
  57553. public function setStatusCode($code)
  57554. {
  57555. $this->statusCode = $code;
  57556. }
  57557. public function getHeaders()
  57558. {
  57559. return $this->headers;
  57560. }
  57561. public function setHeaders(array $headers)
  57562. {
  57563. $this->headers = $headers;
  57564. }
  57565. public function getClass()
  57566. {
  57567. return $this->class;
  57568. }
  57569. public function setClass($class)
  57570. {
  57571. $this->class = $class;
  57572. }
  57573. public function getFile()
  57574. {
  57575. return $this->file;
  57576. }
  57577. public function setFile($file)
  57578. {
  57579. $this->file = $file;
  57580. }
  57581. public function getLine()
  57582. {
  57583. return $this->line;
  57584. }
  57585. public function setLine($line)
  57586. {
  57587. $this->line = $line;
  57588. }
  57589. public function getMessage()
  57590. {
  57591. return $this->message;
  57592. }
  57593. public function setMessage($message)
  57594. {
  57595. $this->message = $message;
  57596. }
  57597. public function getCode()
  57598. {
  57599. return $this->code;
  57600. }
  57601. public function setCode($code)
  57602. {
  57603. $this->code = $code;
  57604. }
  57605. public function getPrevious()
  57606. {
  57607. return $this->previous;
  57608. }
  57609. public function setPrevious(FlattenException $previous)
  57610. {
  57611. $this->previous = $previous;
  57612. }
  57613. public function getAllPrevious()
  57614. {
  57615. $exceptions = array();
  57616. $e = $this;
  57617. while ($e = $e->getPrevious()) {
  57618. $exceptions[] = $e;
  57619. }
  57620. return $exceptions;
  57621. }
  57622. public function getTrace()
  57623. {
  57624. return $this->trace;
  57625. }
  57626. public function setTraceFromException(\Exception $exception)
  57627. {
  57628. $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
  57629. }
  57630. public function setTrace($trace, $file, $line)
  57631. {
  57632. $this->trace = array();
  57633. $this->trace[] = array(
  57634. 'namespace' => '',
  57635. 'short_class' => '',
  57636. 'class' => '',
  57637. 'type' => '',
  57638. 'function' => '',
  57639. 'file' => $file,
  57640. 'line' => $line,
  57641. 'args' => array(),
  57642. );
  57643. foreach ($trace as $entry) {
  57644. $class = '';
  57645. $namespace = '';
  57646. if (isset($entry['class'])) {
  57647. $parts = explode('\\', $entry['class']);
  57648. $class = array_pop($parts);
  57649. $namespace = implode('\\', $parts);
  57650. }
  57651. $this->trace[] = array(
  57652. 'namespace' => $namespace,
  57653. 'short_class' => $class,
  57654. 'class' => isset($entry['class']) ? $entry['class'] : '',
  57655. 'type' => isset($entry['type']) ? $entry['type'] : '',
  57656. 'function' => isset($entry['function']) ? $entry['function'] : null,
  57657. 'file' => isset($entry['file']) ? $entry['file'] : null,
  57658. 'line' => isset($entry['line']) ? $entry['line'] : null,
  57659. 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
  57660. );
  57661. }
  57662. }
  57663. private function flattenArgs($args, $level = 0, &$count = 0)
  57664. {
  57665. $result = array();
  57666. foreach ($args as $key => $value) {
  57667. if (++$count > 1e4) {
  57668. return array('array', '*SKIPPED over 10000 entries*');
  57669. }
  57670. if ($value instanceof \__PHP_Incomplete_Class) {
  57671. $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
  57672. } elseif (\is_object($value)) {
  57673. $result[$key] = array('object', \get_class($value));
  57674. } elseif (\is_array($value)) {
  57675. if ($level > 10) {
  57676. $result[$key] = array('array', '*DEEP NESTED ARRAY*');
  57677. } else {
  57678. $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
  57679. }
  57680. } elseif (null === $value) {
  57681. $result[$key] = array('null', null);
  57682. } elseif (\is_bool($value)) {
  57683. $result[$key] = array('boolean', $value);
  57684. } elseif (\is_resource($value)) {
  57685. $result[$key] = array('resource', get_resource_type($value));
  57686. } else {
  57687. $result[$key] = array('string', (string) $value);
  57688. }
  57689. }
  57690. return $result;
  57691. }
  57692. private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
  57693. {
  57694. $array = new \ArrayObject($value);
  57695. return $array['__PHP_Incomplete_Class_Name'];
  57696. }
  57697. }
  57698. <?php
  57699. namespace Symfony\Component\Debug\Exception;
  57700. class OutOfMemoryException extends FatalErrorException
  57701. {
  57702. }
  57703. <?php
  57704. namespace Symfony\Component\Debug\Exception;
  57705. class UndefinedFunctionException extends FatalErrorException
  57706. {
  57707. public function __construct($message, \ErrorException $previous)
  57708. {
  57709. parent::__construct(
  57710. $message,
  57711. $previous->getCode(),
  57712. $previous->getSeverity(),
  57713. $previous->getFile(),
  57714. $previous->getLine(),
  57715. null,
  57716. true,
  57717. null,
  57718. $previous->getPrevious()
  57719. );
  57720. $this->setTrace($previous->getTrace());
  57721. }
  57722. }
  57723. <?php
  57724. namespace Symfony\Component\Debug\Exception;
  57725. class UndefinedMethodException extends FatalErrorException
  57726. {
  57727. public function __construct($message, \ErrorException $previous)
  57728. {
  57729. parent::__construct(
  57730. $message,
  57731. $previous->getCode(),
  57732. $previous->getSeverity(),
  57733. $previous->getFile(),
  57734. $previous->getLine(),
  57735. null,
  57736. true,
  57737. null,
  57738. $previous->getPrevious()
  57739. );
  57740. $this->setTrace($previous->getTrace());
  57741. }
  57742. }
  57743. <?php
  57744. namespace Symfony\Component\Debug;
  57745. use Symfony\Component\Debug\Exception\FlattenException;
  57746. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  57747. use Symfony\Component\HttpFoundation\Response;
  57748. class ExceptionHandler
  57749. {
  57750. private $debug;
  57751. private $charset;
  57752. private $handler;
  57753. private $caughtBuffer;
  57754. private $caughtLength;
  57755. private $fileLinkFormat;
  57756. public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
  57757. {
  57758. if (false !== strpos($charset, '%')) {
  57759. @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);
  57760. $pivot = $fileLinkFormat;
  57761. $fileLinkFormat = $charset;
  57762. $charset = $pivot;
  57763. }
  57764. $this->debug = $debug;
  57765. $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
  57766. $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
  57767. }
  57768. public static function register($debug = true, $charset = null, $fileLinkFormat = null)
  57769. {
  57770. $handler = new static($debug, $charset, $fileLinkFormat);
  57771. $prev = set_exception_handler(array($handler, 'handle'));
  57772. if (\is_array($prev) && $prev[0] instanceof ErrorHandler) {
  57773. restore_exception_handler();
  57774. $prev[0]->setExceptionHandler(array($handler, 'handle'));
  57775. }
  57776. return $handler;
  57777. }
  57778. public function setHandler($handler)
  57779. {
  57780. if (null !== $handler && !\is_callable($handler)) {
  57781. throw new \LogicException('The exception handler must be a valid PHP callable.');
  57782. }
  57783. $old = $this->handler;
  57784. $this->handler = $handler;
  57785. return $old;
  57786. }
  57787. public function setFileLinkFormat($format)
  57788. {
  57789. $old = $this->fileLinkFormat;
  57790. $this->fileLinkFormat = $format;
  57791. return $old;
  57792. }
  57793. public function handle(\Exception $exception)
  57794. {
  57795. if (null === $this->handler || $exception instanceof OutOfMemoryException) {
  57796. $this->failSafeHandle($exception);
  57797. return;
  57798. }
  57799. $caughtLength = $this->caughtLength = 0;
  57800. ob_start(array($this, 'catchOutput'));
  57801. $this->failSafeHandle($exception);
  57802. while (null === $this->caughtBuffer && ob_end_flush()) {
  57803. }
  57804. if (isset($this->caughtBuffer[0])) {
  57805. ob_start(array($this, 'cleanOutput'));
  57806. echo $this->caughtBuffer;
  57807. $caughtLength = ob_get_length();
  57808. }
  57809. $this->caughtBuffer = null;
  57810. try {
  57811. \call_user_func($this->handler, $exception);
  57812. $this->caughtLength = $caughtLength;
  57813. } catch (\Exception $e) {
  57814. if (!$caughtLength) {
  57815. throw $exception;
  57816. }
  57817. }
  57818. }
  57819. private function failSafeHandle(\Exception $exception)
  57820. {
  57821. if (class_exists('Symfony\Component\HttpFoundation\Response', false)
  57822. && __CLASS__ !== \get_class($this)
  57823. && ($reflector = new \ReflectionMethod($this, 'createResponse'))
  57824. && __CLASS__ !== $reflector->class
  57825. ) {
  57826. $response = $this->createResponse($exception);
  57827. $response->sendHeaders();
  57828. $response->sendContent();
  57829. @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);
  57830. return;
  57831. }
  57832. $this->sendPhpResponse($exception);
  57833. }
  57834. public function sendPhpResponse($exception)
  57835. {
  57836. if (!$exception instanceof FlattenException) {
  57837. $exception = FlattenException::create($exception);
  57838. }
  57839. if (!headers_sent()) {
  57840. header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
  57841. foreach ($exception->getHeaders() as $name => $value) {
  57842. header($name.': '.$value, false);
  57843. }
  57844. header('Content-Type: text/html; charset='.$this->charset);
  57845. }
  57846. echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  57847. }
  57848. public function createResponse($exception)
  57849. {
  57850. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57851. if (!$exception instanceof FlattenException) {
  57852. $exception = FlattenException::create($exception);
  57853. }
  57854. return Response::create($this->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
  57855. }
  57856. public function getHtml($exception)
  57857. {
  57858. if (!$exception instanceof FlattenException) {
  57859. $exception = FlattenException::create($exception);
  57860. }
  57861. return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  57862. }
  57863. public function getContent(FlattenException $exception)
  57864. {
  57865. switch ($exception->getStatusCode()) {
  57866. case 404:
  57867. $title = 'Sorry, the page you are looking for could not be found.';
  57868. break;
  57869. default:
  57870. $title = 'Whoops, looks like something went wrong.';
  57871. }
  57872. $content = '';
  57873. if ($this->debug) {
  57874. try {
  57875. $count = \count($exception->getAllPrevious());
  57876. $total = $count + 1;
  57877. foreach ($exception->toArray() as $position => $e) {
  57878. $ind = $count - $position + 1;
  57879. $class = $this->formatClass($e['class']);
  57880. $message = nl2br($this->escapeHtml($e['message']));
  57881. $content .= sprintf(<<<'EOF'
  57882. <h2 class="block_exception clear_fix">
  57883. <span class="exception_counter">%d/%d</span>
  57884. <span class="exception_title">%s%s:</span>
  57885. <span class="exception_message">%s</span>
  57886. </h2>
  57887. <div class="block">
  57888. <ol class="traces list_exception">
  57889. EOF
  57890. , $ind, $total, $class, $this->formatPath($e['trace'][0]['file'], $e['trace'][0]['line']), $message);
  57891. foreach ($e['trace'] as $trace) {
  57892. $content .= ' <li>';
  57893. if ($trace['function']) {
  57894. $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
  57895. }
  57896. if (isset($trace['file']) && isset($trace['line'])) {
  57897. $content .= $this->formatPath($trace['file'], $trace['line']);
  57898. }
  57899. $content .= "</li>\n";
  57900. }
  57901. $content .= " </ol>\n</div>\n";
  57902. }
  57903. } catch (\Exception $e) {
  57904. if ($this->debug) {
  57905. $title = sprintf('Exception thrown when handling an exception (%s: %s)', \get_class($e), $this->escapeHtml($e->getMessage()));
  57906. } else {
  57907. $title = 'Whoops, looks like something went wrong.';
  57908. }
  57909. }
  57910. }
  57911. return <<<EOF
  57912. <div id="sf-resetcontent" class="sf-reset">
  57913. <h1>$title</h1>
  57914. $content
  57915. </div>
  57916. EOF;
  57917. }
  57918. public function getStylesheet(FlattenException $exception)
  57919. {
  57920. return <<<'EOF'
  57921. .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 }
  57922. .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
  57923. .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
  57924. .sf-reset .clear_fix { display:inline-block; }
  57925. .sf-reset * html .clear_fix { height:1%; }
  57926. .sf-reset .clear_fix { display:block; }
  57927. .sf-reset, .sf-reset .block { margin: auto }
  57928. .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; }
  57929. .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
  57930. .sf-reset strong { font-weight:bold; }
  57931. .sf-reset a { color:#6c6159; cursor: default; }
  57932. .sf-reset a img { border:none; }
  57933. .sf-reset a:hover { text-decoration:underline; }
  57934. .sf-reset em { font-style:italic; }
  57935. .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif }
  57936. .sf-reset .exception_counter { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; float: left; display: block; }
  57937. .sf-reset .exception_title { margin-left: 3em; margin-bottom: 0.7em; display: block; }
  57938. .sf-reset .exception_message { margin-left: 3em; display: block; }
  57939. .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; }
  57940. .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
  57941. -webkit-border-bottom-right-radius: 16px;
  57942. -webkit-border-bottom-left-radius: 16px;
  57943. -moz-border-radius-bottomright: 16px;
  57944. -moz-border-radius-bottomleft: 16px;
  57945. border-bottom-right-radius: 16px;
  57946. border-bottom-left-radius: 16px;
  57947. border-bottom:1px solid #ccc;
  57948. border-right:1px solid #ccc;
  57949. border-left:1px solid #ccc;
  57950. word-wrap: break-word;
  57951. }
  57952. .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px;
  57953. -webkit-border-top-left-radius: 16px;
  57954. -webkit-border-top-right-radius: 16px;
  57955. -moz-border-radius-topleft: 16px;
  57956. -moz-border-radius-topright: 16px;
  57957. border-top-left-radius: 16px;
  57958. border-top-right-radius: 16px;
  57959. border-top:1px solid #ccc;
  57960. border-right:1px solid #ccc;
  57961. border-left:1px solid #ccc;
  57962. overflow: hidden;
  57963. word-wrap: break-word;
  57964. }
  57965. .sf-reset a { background:none; color:#868686; text-decoration:none; }
  57966. .sf-reset a:hover { background:none; color:#313131; text-decoration:underline; }
  57967. .sf-reset ol { padding: 10px 0; }
  57968. .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px;
  57969. -webkit-border-radius: 10px;
  57970. -moz-border-radius: 10px;
  57971. border-radius: 10px;
  57972. border: 1px solid #ccc;
  57973. }
  57974. EOF;
  57975. }
  57976. private function decorate($content, $css)
  57977. {
  57978. return <<<EOF
  57979. <!DOCTYPE html>
  57980. <html>
  57981. <head>
  57982. <meta charset="{$this->charset}" />
  57983. <meta name="robots" content="noindex,nofollow" />
  57984. <style>
  57985. /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
  57986. 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;}
  57987. html { background: #eee; padding: 10px }
  57988. img { border: 0; }
  57989. #sf-resetcontent { width:970px; margin:0 auto; }
  57990. $css
  57991. </style>
  57992. </head>
  57993. <body>
  57994. $content
  57995. </body>
  57996. </html>
  57997. EOF;
  57998. }
  57999. private function formatClass($class)
  58000. {
  58001. $parts = explode('\\', $class);
  58002. return sprintf('<abbr title="%s">%s</abbr>', $class, array_pop($parts));
  58003. }
  58004. private function formatPath($path, $line)
  58005. {
  58006. $path = $this->escapeHtml($path);
  58007. $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
  58008. if ($linkFormat = $this->fileLinkFormat) {
  58009. $link = strtr($this->escapeHtml($linkFormat), array('%f' => $path, '%l' => (int) $line));
  58010. return sprintf(' in <a href="%s" title="Go to source">%s line %d</a>', $link, $file, $line);
  58011. }
  58012. 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);
  58013. }
  58014. private function formatArgs(array $args)
  58015. {
  58016. $result = array();
  58017. foreach ($args as $key => $item) {
  58018. if ('object' === $item[0]) {
  58019. $formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
  58020. } elseif ('array' === $item[0]) {
  58021. $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
  58022. } elseif ('string' === $item[0]) {
  58023. $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
  58024. } elseif ('null' === $item[0]) {
  58025. $formattedValue = '<em>null</em>';
  58026. } elseif ('boolean' === $item[0]) {
  58027. $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
  58028. } elseif ('resource' === $item[0]) {
  58029. $formattedValue = '<em>resource</em>';
  58030. } else {
  58031. $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
  58032. }
  58033. $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue);
  58034. }
  58035. return implode(', ', $result);
  58036. }
  58037. protected static function utf8Htmlize($str)
  58038. {
  58039. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  58040. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
  58041. }
  58042. private function escapeHtml($str)
  58043. {
  58044. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
  58045. }
  58046. public function catchOutput($buffer)
  58047. {
  58048. $this->caughtBuffer = $buffer;
  58049. return '';
  58050. }
  58051. public function cleanOutput($buffer)
  58052. {
  58053. if ($this->caughtLength) {
  58054. $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
  58055. if (isset($cleanBuffer[0])) {
  58056. $buffer = $cleanBuffer;
  58057. }
  58058. }
  58059. return $buffer;
  58060. }
  58061. }
  58062. <?php
  58063. namespace Symfony\Component\Debug\FatalErrorHandler;
  58064. use Composer\Autoload\ClassLoader as ComposerClassLoader;
  58065. use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
  58066. use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
  58067. use Symfony\Component\Debug\DebugClassLoader;
  58068. use Symfony\Component\Debug\Exception\ClassNotFoundException;
  58069. use Symfony\Component\Debug\Exception\FatalErrorException;
  58070. class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
  58071. {
  58072. public function handleError(array $error, FatalErrorException $exception)
  58073. {
  58074. $messageLen = \strlen($error['message']);
  58075. $notFoundSuffix = '\' not found';
  58076. $notFoundSuffixLen = \strlen($notFoundSuffix);
  58077. if ($notFoundSuffixLen > $messageLen) {
  58078. return;
  58079. }
  58080. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  58081. return;
  58082. }
  58083. foreach (array('class', 'interface', 'trait') as $typeName) {
  58084. $prefix = ucfirst($typeName).' \'';
  58085. $prefixLen = \strlen($prefix);
  58086. if (0 !== strpos($error['message'], $prefix)) {
  58087. continue;
  58088. }
  58089. $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  58090. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
  58091. $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
  58092. $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
  58093. $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
  58094. $tail = ' for another namespace?';
  58095. } else {
  58096. $className = $fullyQualifiedClassName;
  58097. $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
  58098. $tail = '?';
  58099. }
  58100. if ($candidates = $this->getClassCandidates($className)) {
  58101. $tail = array_pop($candidates).'"?';
  58102. if ($candidates) {
  58103. $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail;
  58104. } else {
  58105. $tail = ' for "'.$tail;
  58106. }
  58107. }
  58108. $message .= "\nDid you forget a \"use\" statement".$tail;
  58109. return new ClassNotFoundException($message, $exception);
  58110. }
  58111. }
  58112. private function getClassCandidates($class)
  58113. {
  58114. if (!\is_array($functions = spl_autoload_functions())) {
  58115. return array();
  58116. }
  58117. $classes = array();
  58118. foreach ($functions as $function) {
  58119. if (!\is_array($function)) {
  58120. continue;
  58121. }
  58122. if ($function[0] instanceof DebugClassLoader) {
  58123. $function = $function[0]->getClassLoader();
  58124. if (\is_object($function)) {
  58125. $function = array($function);
  58126. }
  58127. if (!\is_array($function)) {
  58128. continue;
  58129. }
  58130. }
  58131. if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) {
  58132. foreach ($function[0]->getPrefixes() as $prefix => $paths) {
  58133. foreach ($paths as $path) {
  58134. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  58135. }
  58136. }
  58137. }
  58138. if ($function[0] instanceof ComposerClassLoader) {
  58139. foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
  58140. foreach ($paths as $path) {
  58141. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  58142. }
  58143. }
  58144. }
  58145. }
  58146. return array_unique($classes);
  58147. }
  58148. private function findClassInPath($path, $class, $prefix)
  58149. {
  58150. if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
  58151. return array();
  58152. }
  58153. $classes = array();
  58154. $filename = $class.'.php';
  58155. foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
  58156. if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
  58157. $classes[] = $class;
  58158. }
  58159. }
  58160. return $classes;
  58161. }
  58162. private function convertFileToClass($path, $file, $prefix)
  58163. {
  58164. $candidates = array(
  58165. $namespacedClass = str_replace(array($path.\DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
  58166. $prefix.$namespacedClass,
  58167. $prefix.'\\'.$namespacedClass,
  58168. str_replace('\\', '_', $namespacedClass),
  58169. str_replace('\\', '_', $prefix.$namespacedClass),
  58170. str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
  58171. );
  58172. if ($prefix) {
  58173. $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
  58174. }
  58175. foreach ($candidates as $candidate) {
  58176. if ($this->classExists($candidate)) {
  58177. return $candidate;
  58178. }
  58179. }
  58180. require_once $file;
  58181. foreach ($candidates as $candidate) {
  58182. if ($this->classExists($candidate)) {
  58183. return $candidate;
  58184. }
  58185. }
  58186. }
  58187. private function classExists($class)
  58188. {
  58189. return class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  58190. }
  58191. }
  58192. <?php
  58193. namespace Symfony\Component\Debug\FatalErrorHandler;
  58194. use Symfony\Component\Debug\Exception\FatalErrorException;
  58195. interface FatalErrorHandlerInterface
  58196. {
  58197. public function handleError(array $error, FatalErrorException $exception);
  58198. }
  58199. <?php
  58200. namespace Symfony\Component\Debug\FatalErrorHandler;
  58201. use Symfony\Component\Debug\Exception\FatalErrorException;
  58202. use Symfony\Component\Debug\Exception\UndefinedFunctionException;
  58203. class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
  58204. {
  58205. public function handleError(array $error, FatalErrorException $exception)
  58206. {
  58207. $messageLen = \strlen($error['message']);
  58208. $notFoundSuffix = '()';
  58209. $notFoundSuffixLen = \strlen($notFoundSuffix);
  58210. if ($notFoundSuffixLen > $messageLen) {
  58211. return;
  58212. }
  58213. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  58214. return;
  58215. }
  58216. $prefix = 'Call to undefined function ';
  58217. $prefixLen = \strlen($prefix);
  58218. if (0 !== strpos($error['message'], $prefix)) {
  58219. return;
  58220. }
  58221. $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  58222. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
  58223. $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
  58224. $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
  58225. $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix);
  58226. } else {
  58227. $functionName = $fullyQualifiedFunctionName;
  58228. $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
  58229. }
  58230. $candidates = array();
  58231. foreach (get_defined_functions() as $type => $definedFunctionNames) {
  58232. foreach ($definedFunctionNames as $definedFunctionName) {
  58233. if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
  58234. $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
  58235. } else {
  58236. $definedFunctionNameBasename = $definedFunctionName;
  58237. }
  58238. if ($definedFunctionNameBasename === $functionName) {
  58239. $candidates[] = '\\'.$definedFunctionName;
  58240. }
  58241. }
  58242. }
  58243. if ($candidates) {
  58244. sort($candidates);
  58245. $last = array_pop($candidates).'"?';
  58246. if ($candidates) {
  58247. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  58248. } else {
  58249. $candidates = '"'.$last;
  58250. }
  58251. $message .= "\nDid you mean to call ".$candidates;
  58252. }
  58253. return new UndefinedFunctionException($message, $exception);
  58254. }
  58255. }
  58256. <?php
  58257. namespace Symfony\Component\Debug\FatalErrorHandler;
  58258. use Symfony\Component\Debug\Exception\FatalErrorException;
  58259. use Symfony\Component\Debug\Exception\UndefinedMethodException;
  58260. class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
  58261. {
  58262. public function handleError(array $error, FatalErrorException $exception)
  58263. {
  58264. preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
  58265. if (!$matches) {
  58266. return;
  58267. }
  58268. $className = $matches[1];
  58269. $methodName = $matches[2];
  58270. $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
  58271. if (!class_exists($className) || null === $methods = get_class_methods($className)) {
  58272. return new UndefinedMethodException($message, $exception);
  58273. }
  58274. $candidates = array();
  58275. foreach ($methods as $definedMethodName) {
  58276. $lev = levenshtein($methodName, $definedMethodName);
  58277. if ($lev <= \strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
  58278. $candidates[] = $definedMethodName;
  58279. }
  58280. }
  58281. if ($candidates) {
  58282. sort($candidates);
  58283. $last = array_pop($candidates).'"?';
  58284. if ($candidates) {
  58285. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  58286. } else {
  58287. $candidates = '"'.$last;
  58288. }
  58289. $message .= "\nDid you mean to call ".$candidates;
  58290. }
  58291. return new UndefinedMethodException($message, $exception);
  58292. }
  58293. }
  58294. Copyright (c) 2004-2018 Fabien Potencier
  58295. Permission is hereby granted, free of charge, to any person obtaining a copy
  58296. of this software and associated documentation files (the "Software"), to deal
  58297. in the Software without restriction, including without limitation the rights
  58298. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58299. copies of the Software, and to permit persons to whom the Software is furnished
  58300. to do so, subject to the following conditions:
  58301. The above copyright notice and this permission notice shall be included in all
  58302. copies or substantial portions of the Software.
  58303. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58304. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58305. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58306. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58307. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58308. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58309. THE SOFTWARE.
  58310. <?php
  58311. namespace Symfony\Component\Filesystem\Exception;
  58312. interface ExceptionInterface
  58313. {
  58314. }
  58315. <?php
  58316. namespace Symfony\Component\Filesystem\Exception;
  58317. class FileNotFoundException extends IOException
  58318. {
  58319. public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null)
  58320. {
  58321. if (null === $message) {
  58322. if (null === $path) {
  58323. $message = 'File could not be found.';
  58324. } else {
  58325. $message = sprintf('File "%s" could not be found.', $path);
  58326. }
  58327. }
  58328. parent::__construct($message, $code, $previous, $path);
  58329. }
  58330. }
  58331. <?php
  58332. namespace Symfony\Component\Filesystem\Exception;
  58333. class IOException extends \RuntimeException implements IOExceptionInterface
  58334. {
  58335. private $path;
  58336. public function __construct($message, $code = 0, \Exception $previous = null, $path = null)
  58337. {
  58338. $this->path = $path;
  58339. parent::__construct($message, $code, $previous);
  58340. }
  58341. public function getPath()
  58342. {
  58343. return $this->path;
  58344. }
  58345. }
  58346. <?php
  58347. namespace Symfony\Component\Filesystem\Exception;
  58348. interface IOExceptionInterface extends ExceptionInterface
  58349. {
  58350. public function getPath();
  58351. }
  58352. <?php
  58353. namespace Symfony\Component\Filesystem;
  58354. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  58355. use Symfony\Component\Filesystem\Exception\IOException;
  58356. class Filesystem
  58357. {
  58358. private static $lastError;
  58359. public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
  58360. {
  58361. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  58362. if ($originIsLocal && !is_file($originFile)) {
  58363. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  58364. }
  58365. $this->mkdir(\dirname($targetFile));
  58366. $doCopy = true;
  58367. if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
  58368. $doCopy = filemtime($originFile) > filemtime($targetFile);
  58369. }
  58370. if ($doCopy) {
  58371. if (false === $source = @fopen($originFile, 'r')) {
  58372. throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
  58373. }
  58374. if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
  58375. throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
  58376. }
  58377. $bytesCopied = stream_copy_to_stream($source, $target);
  58378. fclose($source);
  58379. fclose($target);
  58380. unset($source, $target);
  58381. if (!is_file($targetFile)) {
  58382. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  58383. }
  58384. if ($originIsLocal) {
  58385. @chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  58386. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  58387. 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);
  58388. }
  58389. }
  58390. }
  58391. }
  58392. public function mkdir($dirs, $mode = 0777)
  58393. {
  58394. foreach ($this->toIterator($dirs) as $dir) {
  58395. if (is_dir($dir)) {
  58396. continue;
  58397. }
  58398. if (!self::box('mkdir', $dir, $mode, true)) {
  58399. if (!is_dir($dir)) {
  58400. if (self::$lastError) {
  58401. throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
  58402. }
  58403. throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
  58404. }
  58405. }
  58406. }
  58407. }
  58408. public function exists($files)
  58409. {
  58410. $maxPathLength = PHP_MAXPATHLEN - 2;
  58411. foreach ($this->toIterator($files) as $file) {
  58412. if (\strlen($file) > $maxPathLength) {
  58413. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  58414. }
  58415. if (!file_exists($file)) {
  58416. return false;
  58417. }
  58418. }
  58419. return true;
  58420. }
  58421. public function touch($files, $time = null, $atime = null)
  58422. {
  58423. foreach ($this->toIterator($files) as $file) {
  58424. $touch = $time ? @touch($file, $time, $atime) : @touch($file);
  58425. if (true !== $touch) {
  58426. throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
  58427. }
  58428. }
  58429. }
  58430. public function remove($files)
  58431. {
  58432. if ($files instanceof \Traversable) {
  58433. $files = iterator_to_array($files, false);
  58434. } elseif (!\is_array($files)) {
  58435. $files = array($files);
  58436. }
  58437. $files = array_reverse($files);
  58438. foreach ($files as $file) {
  58439. if (is_link($file)) {
  58440. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  58441. throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
  58442. }
  58443. } elseif (is_dir($file)) {
  58444. $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
  58445. if (!self::box('rmdir', $file) && file_exists($file)) {
  58446. throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
  58447. }
  58448. } elseif (!self::box('unlink', $file) && file_exists($file)) {
  58449. throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
  58450. }
  58451. }
  58452. }
  58453. public function chmod($files, $mode, $umask = 0000, $recursive = false)
  58454. {
  58455. foreach ($this->toIterator($files) as $file) {
  58456. if (true !== @chmod($file, $mode & ~$umask)) {
  58457. throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
  58458. }
  58459. if ($recursive && is_dir($file) && !is_link($file)) {
  58460. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  58461. }
  58462. }
  58463. }
  58464. public function chown($files, $user, $recursive = false)
  58465. {
  58466. foreach ($this->toIterator($files) as $file) {
  58467. if ($recursive && is_dir($file) && !is_link($file)) {
  58468. $this->chown(new \FilesystemIterator($file), $user, true);
  58469. }
  58470. if (is_link($file) && \function_exists('lchown')) {
  58471. if (true !== @lchown($file, $user)) {
  58472. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  58473. }
  58474. } else {
  58475. if (true !== @chown($file, $user)) {
  58476. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  58477. }
  58478. }
  58479. }
  58480. }
  58481. public function chgrp($files, $group, $recursive = false)
  58482. {
  58483. foreach ($this->toIterator($files) as $file) {
  58484. if ($recursive && is_dir($file) && !is_link($file)) {
  58485. $this->chgrp(new \FilesystemIterator($file), $group, true);
  58486. }
  58487. if (is_link($file) && \function_exists('lchgrp')) {
  58488. if (true !== @lchgrp($file, $group) || (\defined('HHVM_VERSION') && !posix_getgrnam($group))) {
  58489. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  58490. }
  58491. } else {
  58492. if (true !== @chgrp($file, $group)) {
  58493. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  58494. }
  58495. }
  58496. }
  58497. }
  58498. public function rename($origin, $target, $overwrite = false)
  58499. {
  58500. if (!$overwrite && $this->isReadable($target)) {
  58501. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  58502. }
  58503. if (true !== @rename($origin, $target)) {
  58504. if (is_dir($origin)) {
  58505. $this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
  58506. $this->remove($origin);
  58507. return;
  58508. }
  58509. throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
  58510. }
  58511. }
  58512. private function isReadable($filename)
  58513. {
  58514. $maxPathLength = PHP_MAXPATHLEN - 2;
  58515. if (\strlen($filename) > $maxPathLength) {
  58516. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  58517. }
  58518. return is_readable($filename);
  58519. }
  58520. public function symlink($originDir, $targetDir, $copyOnWindows = false)
  58521. {
  58522. if ('\\' === \DIRECTORY_SEPARATOR) {
  58523. $originDir = strtr($originDir, '/', '\\');
  58524. $targetDir = strtr($targetDir, '/', '\\');
  58525. if ($copyOnWindows) {
  58526. $this->mirror($originDir, $targetDir);
  58527. return;
  58528. }
  58529. }
  58530. $this->mkdir(\dirname($targetDir));
  58531. if (is_link($targetDir)) {
  58532. if (readlink($targetDir) === $originDir) {
  58533. return;
  58534. }
  58535. $this->remove($targetDir);
  58536. }
  58537. if (!self::box('symlink', $originDir, $targetDir)) {
  58538. if (null !== self::$lastError) {
  58539. if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) {
  58540. 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);
  58541. }
  58542. }
  58543. throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
  58544. }
  58545. }
  58546. public function makePathRelative($endPath, $startPath)
  58547. {
  58548. if ('\\' === \DIRECTORY_SEPARATOR) {
  58549. $endPath = str_replace('\\', '/', $endPath);
  58550. $startPath = str_replace('\\', '/', $startPath);
  58551. }
  58552. $stripDriveLetter = function ($path) {
  58553. if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
  58554. return substr($path, 2);
  58555. }
  58556. return $path;
  58557. };
  58558. $endPath = $stripDriveLetter($endPath);
  58559. $startPath = $stripDriveLetter($startPath);
  58560. $startPathArr = explode('/', trim($startPath, '/'));
  58561. $endPathArr = explode('/', trim($endPath, '/'));
  58562. $normalizePathArray = function ($pathSegments, $absolute) {
  58563. $result = array();
  58564. foreach ($pathSegments as $segment) {
  58565. if ('..' === $segment && ($absolute || \count($result))) {
  58566. array_pop($result);
  58567. } elseif ('.' !== $segment) {
  58568. $result[] = $segment;
  58569. }
  58570. }
  58571. return $result;
  58572. };
  58573. $startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
  58574. $endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
  58575. $index = 0;
  58576. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  58577. ++$index;
  58578. }
  58579. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  58580. $depth = 0;
  58581. } else {
  58582. $depth = \count($startPathArr) - $index;
  58583. }
  58584. $traverser = str_repeat('../', $depth);
  58585. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  58586. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  58587. return '' === $relativePath ? './' : $relativePath;
  58588. }
  58589. public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
  58590. {
  58591. $targetDir = rtrim($targetDir, '/\\');
  58592. $originDir = rtrim($originDir, '/\\');
  58593. $originDirLen = \strlen($originDir);
  58594. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  58595. $deleteIterator = $iterator;
  58596. if (null === $deleteIterator) {
  58597. $flags = \FilesystemIterator::SKIP_DOTS;
  58598. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  58599. }
  58600. $targetDirLen = \strlen($targetDir);
  58601. foreach ($deleteIterator as $file) {
  58602. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  58603. if (!$this->exists($origin)) {
  58604. $this->remove($file);
  58605. }
  58606. }
  58607. }
  58608. $copyOnWindows = false;
  58609. if (isset($options['copy_on_windows'])) {
  58610. $copyOnWindows = $options['copy_on_windows'];
  58611. }
  58612. if (null === $iterator) {
  58613. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  58614. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  58615. }
  58616. if ($this->exists($originDir)) {
  58617. $this->mkdir($targetDir);
  58618. }
  58619. foreach ($iterator as $file) {
  58620. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  58621. if ($copyOnWindows) {
  58622. if (is_file($file)) {
  58623. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  58624. } elseif (is_dir($file)) {
  58625. $this->mkdir($target);
  58626. } else {
  58627. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  58628. }
  58629. } else {
  58630. if (is_link($file)) {
  58631. $this->symlink($file->getLinkTarget(), $target);
  58632. } elseif (is_dir($file)) {
  58633. $this->mkdir($target);
  58634. } elseif (is_file($file)) {
  58635. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  58636. } else {
  58637. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  58638. }
  58639. }
  58640. }
  58641. }
  58642. public function isAbsolutePath($file)
  58643. {
  58644. return strspn($file, '/\\', 0, 1)
  58645. || (\strlen($file) > 3 && ctype_alpha($file[0])
  58646. && ':' === substr($file, 1, 1)
  58647. && strspn($file, '/\\', 2, 1)
  58648. )
  58649. || null !== parse_url($file, PHP_URL_SCHEME)
  58650. ;
  58651. }
  58652. public function tempnam($dir, $prefix)
  58653. {
  58654. list($scheme, $hierarchy) = $this->getSchemeAndHierarchy($dir);
  58655. if (null === $scheme || 'file' === $scheme || 'gs' === $scheme) {
  58656. $tmpFile = @tempnam($hierarchy, $prefix);
  58657. if (false !== $tmpFile) {
  58658. if (null !== $scheme && 'gs' !== $scheme) {
  58659. return $scheme.'://'.$tmpFile;
  58660. }
  58661. return $tmpFile;
  58662. }
  58663. throw new IOException('A temporary file could not be created.');
  58664. }
  58665. for ($i = 0; $i < 10; ++$i) {
  58666. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true);
  58667. $handle = @fopen($tmpFile, 'x+');
  58668. if (false === $handle) {
  58669. continue;
  58670. }
  58671. @fclose($handle);
  58672. return $tmpFile;
  58673. }
  58674. throw new IOException('A temporary file could not be created.');
  58675. }
  58676. public function dumpFile($filename, $content, $mode = 0666)
  58677. {
  58678. $dir = \dirname($filename);
  58679. if (!is_dir($dir)) {
  58680. $this->mkdir($dir);
  58681. }
  58682. if (!is_writable($dir)) {
  58683. throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
  58684. }
  58685. $tmpFile = $this->tempnam($dir, basename($filename));
  58686. if (false === @file_put_contents($tmpFile, $content)) {
  58687. throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
  58688. }
  58689. if (null !== $mode) {
  58690. if (\func_num_args() > 2) {
  58691. @trigger_error('Support for modifying file permissions is deprecated since Symfony 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
  58692. }
  58693. $this->chmod($tmpFile, $mode);
  58694. } elseif (file_exists($filename)) {
  58695. @chmod($tmpFile, fileperms($filename));
  58696. }
  58697. $this->rename($tmpFile, $filename, true);
  58698. }
  58699. private function toIterator($files)
  58700. {
  58701. if (!$files instanceof \Traversable) {
  58702. $files = new \ArrayObject(\is_array($files) ? $files : array($files));
  58703. }
  58704. return $files;
  58705. }
  58706. private function getSchemeAndHierarchy($filename)
  58707. {
  58708. $components = explode('://', $filename, 2);
  58709. return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
  58710. }
  58711. private static function box($func)
  58712. {
  58713. self::$lastError = null;
  58714. \set_error_handler(__CLASS__.'::handleError');
  58715. try {
  58716. $result = \call_user_func_array($func, \array_slice(\func_get_args(), 1));
  58717. \restore_error_handler();
  58718. return $result;
  58719. } catch (\Throwable $e) {
  58720. } catch (\Exception $e) {
  58721. }
  58722. \restore_error_handler();
  58723. throw $e;
  58724. }
  58725. public static function handleError($type, $msg)
  58726. {
  58727. self::$lastError = $msg;
  58728. }
  58729. }
  58730. Copyright (c) 2004-2018 Fabien Potencier
  58731. Permission is hereby granted, free of charge, to any person obtaining a copy
  58732. of this software and associated documentation files (the "Software"), to deal
  58733. in the Software without restriction, including without limitation the rights
  58734. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58735. copies of the Software, and to permit persons to whom the Software is furnished
  58736. to do so, subject to the following conditions:
  58737. The above copyright notice and this permission notice shall be included in all
  58738. copies or substantial portions of the Software.
  58739. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58740. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58741. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58742. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58743. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58744. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58745. THE SOFTWARE.
  58746. <?php
  58747. namespace Symfony\Component\Filesystem;
  58748. use Symfony\Component\Filesystem\Exception\IOException;
  58749. class LockHandler
  58750. {
  58751. private $file;
  58752. private $handle;
  58753. public function __construct($name, $lockPath = null)
  58754. {
  58755. $lockPath = $lockPath ?: sys_get_temp_dir();
  58756. if (!is_dir($lockPath)) {
  58757. $fs = new Filesystem();
  58758. $fs->mkdir($lockPath);
  58759. }
  58760. if (!is_writable($lockPath)) {
  58761. throw new IOException(sprintf('The directory "%s" is not writable.', $lockPath), 0, null, $lockPath);
  58762. }
  58763. $this->file = sprintf('%s/sf.%s.%s.lock', $lockPath, preg_replace('/[^a-z0-9\._-]+/i', '-', $name), hash('sha256', $name));
  58764. }
  58765. public function lock($blocking = false)
  58766. {
  58767. if ($this->handle) {
  58768. return true;
  58769. }
  58770. $error = null;
  58771. set_error_handler(function ($errno, $msg) use (&$error) {
  58772. $error = $msg;
  58773. });
  58774. if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  58775. if ($this->handle = fopen($this->file, 'x')) {
  58776. chmod($this->file, 0666);
  58777. } elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  58778. usleep(100);
  58779. $this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
  58780. }
  58781. }
  58782. restore_error_handler();
  58783. if (!$this->handle) {
  58784. throw new IOException($error, 0, null, $this->file);
  58785. }
  58786. if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
  58787. fclose($this->handle);
  58788. $this->handle = null;
  58789. return false;
  58790. }
  58791. return true;
  58792. }
  58793. public function release()
  58794. {
  58795. if ($this->handle) {
  58796. flock($this->handle, LOCK_UN | LOCK_NB);
  58797. fclose($this->handle);
  58798. $this->handle = null;
  58799. }
  58800. }
  58801. }
  58802. <?php
  58803. namespace Symfony\Component\Finder\Adapter;
  58804. @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);
  58805. abstract class AbstractAdapter implements AdapterInterface
  58806. {
  58807. protected $followLinks = false;
  58808. protected $mode = 0;
  58809. protected $minDepth = 0;
  58810. protected $maxDepth = PHP_INT_MAX;
  58811. protected $exclude = array();
  58812. protected $names = array();
  58813. protected $notNames = array();
  58814. protected $contains = array();
  58815. protected $notContains = array();
  58816. protected $sizes = array();
  58817. protected $dates = array();
  58818. protected $filters = array();
  58819. protected $sort = false;
  58820. protected $paths = array();
  58821. protected $notPaths = array();
  58822. protected $ignoreUnreadableDirs = false;
  58823. private static $areSupported = array();
  58824. public function isSupported()
  58825. {
  58826. $name = $this->getName();
  58827. if (!array_key_exists($name, self::$areSupported)) {
  58828. self::$areSupported[$name] = $this->canBeUsed();
  58829. }
  58830. return self::$areSupported[$name];
  58831. }
  58832. public function setFollowLinks($followLinks)
  58833. {
  58834. $this->followLinks = $followLinks;
  58835. return $this;
  58836. }
  58837. public function setMode($mode)
  58838. {
  58839. $this->mode = $mode;
  58840. return $this;
  58841. }
  58842. public function setDepths(array $depths)
  58843. {
  58844. $this->minDepth = 0;
  58845. $this->maxDepth = PHP_INT_MAX;
  58846. foreach ($depths as $comparator) {
  58847. switch ($comparator->getOperator()) {
  58848. case '>':
  58849. $this->minDepth = $comparator->getTarget() + 1;
  58850. break;
  58851. case '>=':
  58852. $this->minDepth = $comparator->getTarget();
  58853. break;
  58854. case '<':
  58855. $this->maxDepth = $comparator->getTarget() - 1;
  58856. break;
  58857. case '<=':
  58858. $this->maxDepth = $comparator->getTarget();
  58859. break;
  58860. default:
  58861. $this->minDepth = $this->maxDepth = $comparator->getTarget();
  58862. }
  58863. }
  58864. return $this;
  58865. }
  58866. public function setExclude(array $exclude)
  58867. {
  58868. $this->exclude = $exclude;
  58869. return $this;
  58870. }
  58871. public function setNames(array $names)
  58872. {
  58873. $this->names = $names;
  58874. return $this;
  58875. }
  58876. public function setNotNames(array $notNames)
  58877. {
  58878. $this->notNames = $notNames;
  58879. return $this;
  58880. }
  58881. public function setContains(array $contains)
  58882. {
  58883. $this->contains = $contains;
  58884. return $this;
  58885. }
  58886. public function setNotContains(array $notContains)
  58887. {
  58888. $this->notContains = $notContains;
  58889. return $this;
  58890. }
  58891. public function setSizes(array $sizes)
  58892. {
  58893. $this->sizes = $sizes;
  58894. return $this;
  58895. }
  58896. public function setDates(array $dates)
  58897. {
  58898. $this->dates = $dates;
  58899. return $this;
  58900. }
  58901. public function setFilters(array $filters)
  58902. {
  58903. $this->filters = $filters;
  58904. return $this;
  58905. }
  58906. public function setSort($sort)
  58907. {
  58908. $this->sort = $sort;
  58909. return $this;
  58910. }
  58911. public function setPath(array $paths)
  58912. {
  58913. $this->paths = $paths;
  58914. return $this;
  58915. }
  58916. public function setNotPath(array $notPaths)
  58917. {
  58918. $this->notPaths = $notPaths;
  58919. return $this;
  58920. }
  58921. public function ignoreUnreadableDirs($ignore = true)
  58922. {
  58923. $this->ignoreUnreadableDirs = (bool) $ignore;
  58924. return $this;
  58925. }
  58926. abstract protected function canBeUsed();
  58927. }
  58928. <?php
  58929. namespace Symfony\Component\Finder\Adapter;
  58930. @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);
  58931. use Symfony\Component\Finder\Comparator\DateComparator;
  58932. use Symfony\Component\Finder\Comparator\NumberComparator;
  58933. use Symfony\Component\Finder\Exception\AccessDeniedException;
  58934. use Symfony\Component\Finder\Expression\Expression;
  58935. use Symfony\Component\Finder\Iterator;
  58936. use Symfony\Component\Finder\Shell\Command;
  58937. use Symfony\Component\Finder\Shell\Shell;
  58938. abstract class AbstractFindAdapter extends AbstractAdapter
  58939. {
  58940. protected $shell;
  58941. public function __construct()
  58942. {
  58943. $this->shell = new Shell();
  58944. }
  58945. public function searchInDirectory($dir)
  58946. {
  58947. $dir = realpath($dir);
  58948. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) {
  58949. return new Iterator\FilePathsIterator(array(), $dir);
  58950. }
  58951. $command = Command::create();
  58952. $find = $this->buildFindCommand($command, $dir);
  58953. if ($this->followLinks) {
  58954. $find->add('-follow');
  58955. }
  58956. $find->add('-mindepth')->add($this->minDepth + 1);
  58957. if (PHP_INT_MAX !== $this->maxDepth) {
  58958. $find->add('-maxdepth')->add($this->maxDepth + 1);
  58959. }
  58960. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) {
  58961. $find->add('-type d');
  58962. } elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) {
  58963. $find->add('-type f');
  58964. }
  58965. $this->buildNamesFiltering($find, $this->names);
  58966. $this->buildNamesFiltering($find, $this->notNames, true);
  58967. $this->buildPathsFiltering($find, $dir, $this->paths);
  58968. $this->buildPathsFiltering($find, $dir, $this->notPaths, true);
  58969. $this->buildSizesFiltering($find, $this->sizes);
  58970. $this->buildDatesFiltering($find, $this->dates);
  58971. $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
  58972. $useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut');
  58973. if ($useGrep && ($this->contains || $this->notContains)) {
  58974. $grep = $command->ins('grep');
  58975. $this->buildContentFiltering($grep, $this->contains);
  58976. $this->buildContentFiltering($grep, $this->notContains, true);
  58977. }
  58978. if ($useSort) {
  58979. $this->buildSorting($command, $this->sort);
  58980. }
  58981. $command->setErrorHandler(
  58982. $this->ignoreUnreadableDirs
  58983. ? function ($stderr) { }
  58984. : function ($stderr) { throw new AccessDeniedException($stderr); }
  58985. );
  58986. $paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
  58987. $iterator = new Iterator\FilePathsIterator($paths, $dir);
  58988. if ($this->exclude) {
  58989. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  58990. }
  58991. if (!$useGrep && ($this->contains || $this->notContains)) {
  58992. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  58993. }
  58994. if ($this->filters) {
  58995. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  58996. }
  58997. if (!$useSort && $this->sort) {
  58998. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  58999. $iterator = $iteratorAggregate->getIterator();
  59000. }
  59001. return $iterator;
  59002. }
  59003. protected function canBeUsed()
  59004. {
  59005. return $this->shell->testCommand('find');
  59006. }
  59007. protected function buildFindCommand(Command $command, $dir)
  59008. {
  59009. return $command
  59010. ->ins('find')
  59011. ->add('find ')
  59012. ->arg($dir)
  59013. ->add('-noleaf');
  59014. }
  59015. private function buildNamesFiltering(Command $command, array $names, $not = false)
  59016. {
  59017. if (0 === \count($names)) {
  59018. return;
  59019. }
  59020. $command->add($not ? '-not' : null)->cmd('(');
  59021. foreach ($names as $i => $name) {
  59022. $expr = Expression::create($name);
  59023. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  59024. $expr = Expression::create($expr->getGlob()->toRegex(false));
  59025. }
  59026. if ($expr->isRegex()) {
  59027. $regex = $expr->getRegex();
  59028. $regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*')
  59029. ->setStartFlag(false)
  59030. ->setStartJoker(true)
  59031. ->replaceJokers('[^/]');
  59032. if (!$regex->hasEndFlag() || $regex->hasEndJoker()) {
  59033. $regex->setEndJoker(false)->append('[^/]*');
  59034. }
  59035. }
  59036. $command
  59037. ->add($i > 0 ? '-or' : null)
  59038. ->add($expr->isRegex()
  59039. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  59040. : ($expr->isCaseSensitive() ? '-name' : '-iname')
  59041. )
  59042. ->arg($expr->renderPattern());
  59043. }
  59044. $command->cmd(')');
  59045. }
  59046. private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
  59047. {
  59048. if (0 === \count($paths)) {
  59049. return;
  59050. }
  59051. $command->add($not ? '-not' : null)->cmd('(');
  59052. foreach ($paths as $i => $path) {
  59053. $expr = Expression::create($path);
  59054. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  59055. $expr = Expression::create($expr->getGlob()->toRegex(false));
  59056. }
  59057. if ($expr->isRegex()) {
  59058. $regex = $expr->getRegex();
  59059. $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
  59060. } else {
  59061. $expr->prepend('*')->append('*');
  59062. }
  59063. $command
  59064. ->add($i > 0 ? '-or' : null)
  59065. ->add($expr->isRegex()
  59066. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  59067. : ($expr->isCaseSensitive() ? '-path' : '-ipath')
  59068. )
  59069. ->arg($expr->renderPattern());
  59070. }
  59071. $command->cmd(')');
  59072. }
  59073. private function buildSizesFiltering(Command $command, array $sizes)
  59074. {
  59075. foreach ($sizes as $i => $size) {
  59076. $command->add($i > 0 ? '-and' : null);
  59077. switch ($size->getOperator()) {
  59078. case '<=':
  59079. $command->add('-size -'.($size->getTarget() + 1).'c');
  59080. break;
  59081. case '>=':
  59082. $command->add('-size +'.($size->getTarget() - 1).'c');
  59083. break;
  59084. case '>':
  59085. $command->add('-size +'.$size->getTarget().'c');
  59086. break;
  59087. case '!=':
  59088. $command->add('-size -'.$size->getTarget().'c');
  59089. $command->add('-size +'.$size->getTarget().'c');
  59090. break;
  59091. case '<':
  59092. default:
  59093. $command->add('-size -'.$size->getTarget().'c');
  59094. }
  59095. }
  59096. }
  59097. private function buildDatesFiltering(Command $command, array $dates)
  59098. {
  59099. foreach ($dates as $i => $date) {
  59100. $command->add($i > 0 ? '-and' : null);
  59101. $mins = (int) round((time() - $date->getTarget()) / 60);
  59102. if (0 > $mins) {
  59103. $command->add(' -mmin -0');
  59104. return;
  59105. }
  59106. switch ($date->getOperator()) {
  59107. case '<=':
  59108. $command->add('-mmin +'.($mins - 1));
  59109. break;
  59110. case '>=':
  59111. $command->add('-mmin -'.($mins + 1));
  59112. break;
  59113. case '>':
  59114. $command->add('-mmin -'.$mins);
  59115. break;
  59116. case '!=':
  59117. $command->add('-mmin +'.$mins.' -or -mmin -'.$mins);
  59118. break;
  59119. case '<':
  59120. default:
  59121. $command->add('-mmin +'.$mins);
  59122. }
  59123. }
  59124. }
  59125. private function buildSorting(Command $command, $sort)
  59126. {
  59127. $this->buildFormatSorting($command, $sort);
  59128. }
  59129. abstract protected function buildFormatSorting(Command $command, $sort);
  59130. abstract protected function buildContentFiltering(Command $command, array $contains, $not = false);
  59131. }
  59132. <?php
  59133. namespace Symfony\Component\Finder\Adapter;
  59134. interface AdapterInterface
  59135. {
  59136. public function setFollowLinks($followLinks);
  59137. public function setMode($mode);
  59138. public function setExclude(array $exclude);
  59139. public function setDepths(array $depths);
  59140. public function setNames(array $names);
  59141. public function setNotNames(array $notNames);
  59142. public function setContains(array $contains);
  59143. public function setNotContains(array $notContains);
  59144. public function setSizes(array $sizes);
  59145. public function setDates(array $dates);
  59146. public function setFilters(array $filters);
  59147. public function setSort($sort);
  59148. public function setPath(array $paths);
  59149. public function setNotPath(array $notPaths);
  59150. public function ignoreUnreadableDirs($ignore = true);
  59151. public function searchInDirectory($dir);
  59152. public function isSupported();
  59153. public function getName();
  59154. }
  59155. <?php
  59156. namespace Symfony\Component\Finder\Adapter;
  59157. @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);
  59158. use Symfony\Component\Finder\Expression\Expression;
  59159. use Symfony\Component\Finder\Iterator\SortableIterator;
  59160. use Symfony\Component\Finder\Shell\Command;
  59161. use Symfony\Component\Finder\Shell\Shell;
  59162. class BsdFindAdapter extends AbstractFindAdapter
  59163. {
  59164. public function getName()
  59165. {
  59166. return 'bsd_find';
  59167. }
  59168. protected function canBeUsed()
  59169. {
  59170. return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
  59171. }
  59172. protected function buildFormatSorting(Command $command, $sort)
  59173. {
  59174. switch ($sort) {
  59175. case SortableIterator::SORT_BY_NAME:
  59176. $command->ins('sort')->add('| sort');
  59177. return;
  59178. case SortableIterator::SORT_BY_TYPE:
  59179. $format = '%HT';
  59180. break;
  59181. case SortableIterator::SORT_BY_ACCESSED_TIME:
  59182. $format = '%a';
  59183. break;
  59184. case SortableIterator::SORT_BY_CHANGED_TIME:
  59185. $format = '%c';
  59186. break;
  59187. case SortableIterator::SORT_BY_MODIFIED_TIME:
  59188. $format = '%m';
  59189. break;
  59190. default:
  59191. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  59192. }
  59193. $command
  59194. ->add('-print0 | xargs -0 stat -f')
  59195. ->arg($format.'%t%N')
  59196. ->add('| sort | cut -f 2');
  59197. }
  59198. protected function buildFindCommand(Command $command, $dir)
  59199. {
  59200. parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
  59201. return $command;
  59202. }
  59203. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  59204. {
  59205. foreach ($contains as $contain) {
  59206. $expr = Expression::create($contain);
  59207. $command
  59208. ->add('| grep -v \'^$\'')
  59209. ->add('| xargs -I{} grep -I')
  59210. ->add($expr->isCaseSensitive() ? null : '-i')
  59211. ->add($not ? '-L' : '-l')
  59212. ->add('-Ee')->arg($expr->renderPattern())
  59213. ->add('{}')
  59214. ;
  59215. }
  59216. }
  59217. }
  59218. <?php
  59219. namespace Symfony\Component\Finder\Adapter;
  59220. @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);
  59221. use Symfony\Component\Finder\Expression\Expression;
  59222. use Symfony\Component\Finder\Iterator\SortableIterator;
  59223. use Symfony\Component\Finder\Shell\Command;
  59224. use Symfony\Component\Finder\Shell\Shell;
  59225. class GnuFindAdapter extends AbstractFindAdapter
  59226. {
  59227. public function getName()
  59228. {
  59229. return 'gnu_find';
  59230. }
  59231. protected function buildFormatSorting(Command $command, $sort)
  59232. {
  59233. switch ($sort) {
  59234. case SortableIterator::SORT_BY_NAME:
  59235. $command->ins('sort')->add('| sort');
  59236. return;
  59237. case SortableIterator::SORT_BY_TYPE:
  59238. $format = '%y';
  59239. break;
  59240. case SortableIterator::SORT_BY_ACCESSED_TIME:
  59241. $format = '%A@';
  59242. break;
  59243. case SortableIterator::SORT_BY_CHANGED_TIME:
  59244. $format = '%C@';
  59245. break;
  59246. case SortableIterator::SORT_BY_MODIFIED_TIME:
  59247. $format = '%T@';
  59248. break;
  59249. default:
  59250. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  59251. }
  59252. $command
  59253. ->get('find')
  59254. ->add('-printf')
  59255. ->arg($format.' %h/%f\\n')
  59256. ->add('| sort | cut')
  59257. ->arg('-d ')
  59258. ->arg('-f2-')
  59259. ;
  59260. }
  59261. protected function canBeUsed()
  59262. {
  59263. return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
  59264. }
  59265. protected function buildFindCommand(Command $command, $dir)
  59266. {
  59267. return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
  59268. }
  59269. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  59270. {
  59271. foreach ($contains as $contain) {
  59272. $expr = Expression::create($contain);
  59273. $command
  59274. ->add('| xargs -I{} -r grep -I')
  59275. ->add($expr->isCaseSensitive() ? null : '-i')
  59276. ->add($not ? '-L' : '-l')
  59277. ->add('-Ee')->arg($expr->renderPattern())
  59278. ->add('{}')
  59279. ;
  59280. }
  59281. }
  59282. }
  59283. <?php
  59284. namespace Symfony\Component\Finder\Adapter;
  59285. @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);
  59286. use Symfony\Component\Finder\Iterator;
  59287. class PhpAdapter extends AbstractAdapter
  59288. {
  59289. public function searchInDirectory($dir)
  59290. {
  59291. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  59292. if ($this->followLinks) {
  59293. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  59294. }
  59295. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  59296. if ($this->exclude) {
  59297. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  59298. }
  59299. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  59300. if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
  59301. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
  59302. }
  59303. if ($this->mode) {
  59304. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  59305. }
  59306. if ($this->names || $this->notNames) {
  59307. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  59308. }
  59309. if ($this->contains || $this->notContains) {
  59310. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  59311. }
  59312. if ($this->sizes) {
  59313. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  59314. }
  59315. if ($this->dates) {
  59316. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  59317. }
  59318. if ($this->filters) {
  59319. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  59320. }
  59321. if ($this->paths || $this->notPaths) {
  59322. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  59323. }
  59324. if ($this->sort) {
  59325. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  59326. $iterator = $iteratorAggregate->getIterator();
  59327. }
  59328. return $iterator;
  59329. }
  59330. public function getName()
  59331. {
  59332. return 'php';
  59333. }
  59334. protected function canBeUsed()
  59335. {
  59336. return true;
  59337. }
  59338. }
  59339. <?php
  59340. namespace Symfony\Component\Finder\Comparator;
  59341. class Comparator
  59342. {
  59343. private $target;
  59344. private $operator = '==';
  59345. public function getTarget()
  59346. {
  59347. return $this->target;
  59348. }
  59349. public function setTarget($target)
  59350. {
  59351. $this->target = $target;
  59352. }
  59353. public function getOperator()
  59354. {
  59355. return $this->operator;
  59356. }
  59357. public function setOperator($operator)
  59358. {
  59359. if (!$operator) {
  59360. $operator = '==';
  59361. }
  59362. if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
  59363. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  59364. }
  59365. $this->operator = $operator;
  59366. }
  59367. public function test($test)
  59368. {
  59369. switch ($this->operator) {
  59370. case '>':
  59371. return $test > $this->target;
  59372. case '>=':
  59373. return $test >= $this->target;
  59374. case '<':
  59375. return $test < $this->target;
  59376. case '<=':
  59377. return $test <= $this->target;
  59378. case '!=':
  59379. return $test != $this->target;
  59380. }
  59381. return $test == $this->target;
  59382. }
  59383. }
  59384. <?php
  59385. namespace Symfony\Component\Finder\Comparator;
  59386. class DateComparator extends Comparator
  59387. {
  59388. public function __construct($test)
  59389. {
  59390. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  59391. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  59392. }
  59393. try {
  59394. $date = new \DateTime($matches[2]);
  59395. $target = $date->format('U');
  59396. } catch (\Exception $e) {
  59397. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  59398. }
  59399. $operator = isset($matches[1]) ? $matches[1] : '==';
  59400. if ('since' === $operator || 'after' === $operator) {
  59401. $operator = '>';
  59402. }
  59403. if ('until' === $operator || 'before' === $operator) {
  59404. $operator = '<';
  59405. }
  59406. $this->setOperator($operator);
  59407. $this->setTarget($target);
  59408. }
  59409. }
  59410. <?php
  59411. namespace Symfony\Component\Finder\Comparator;
  59412. class NumberComparator extends Comparator
  59413. {
  59414. public function __construct($test)
  59415. {
  59416. if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  59417. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
  59418. }
  59419. $target = $matches[2];
  59420. if (!is_numeric($target)) {
  59421. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  59422. }
  59423. if (isset($matches[3])) {
  59424. switch (strtolower($matches[3])) {
  59425. case 'k':
  59426. $target *= 1000;
  59427. break;
  59428. case 'ki':
  59429. $target *= 1024;
  59430. break;
  59431. case 'm':
  59432. $target *= 1000000;
  59433. break;
  59434. case 'mi':
  59435. $target *= 1024 * 1024;
  59436. break;
  59437. case 'g':
  59438. $target *= 1000000000;
  59439. break;
  59440. case 'gi':
  59441. $target *= 1024 * 1024 * 1024;
  59442. break;
  59443. }
  59444. }
  59445. $this->setTarget($target);
  59446. $this->setOperator(isset($matches[1]) ? $matches[1] : '==');
  59447. }
  59448. }
  59449. <?php
  59450. namespace Symfony\Component\Finder\Exception;
  59451. class AccessDeniedException extends \UnexpectedValueException
  59452. {
  59453. }
  59454. <?php
  59455. namespace Symfony\Component\Finder\Exception;
  59456. @trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59457. use Symfony\Component\Finder\Adapter\AdapterInterface;
  59458. class AdapterFailureException extends \RuntimeException implements ExceptionInterface
  59459. {
  59460. private $adapter;
  59461. public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
  59462. {
  59463. $this->adapter = $adapter;
  59464. parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous);
  59465. }
  59466. public function getAdapter()
  59467. {
  59468. return $this->adapter;
  59469. }
  59470. }
  59471. <?php
  59472. namespace Symfony\Component\Finder\Exception;
  59473. interface ExceptionInterface
  59474. {
  59475. public function getAdapter();
  59476. }
  59477. <?php
  59478. namespace Symfony\Component\Finder\Exception;
  59479. @trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59480. class OperationNotPermitedException extends AdapterFailureException
  59481. {
  59482. }
  59483. <?php
  59484. namespace Symfony\Component\Finder\Exception;
  59485. @trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59486. use Symfony\Component\Finder\Adapter\AdapterInterface;
  59487. use Symfony\Component\Finder\Shell\Command;
  59488. class ShellCommandFailureException extends AdapterFailureException
  59489. {
  59490. private $command;
  59491. public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
  59492. {
  59493. $this->command = $command;
  59494. parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous);
  59495. }
  59496. public function getCommand()
  59497. {
  59498. return $this->command;
  59499. }
  59500. }
  59501. <?php
  59502. namespace Symfony\Component\Finder\Expression;
  59503. @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59504. class Expression implements ValueInterface
  59505. {
  59506. const TYPE_REGEX = 1;
  59507. const TYPE_GLOB = 2;
  59508. private $value;
  59509. public static function create($expr)
  59510. {
  59511. return new self($expr);
  59512. }
  59513. public function __construct($expr)
  59514. {
  59515. try {
  59516. $this->value = Regex::create($expr);
  59517. } catch (\InvalidArgumentException $e) {
  59518. $this->value = new Glob($expr);
  59519. }
  59520. }
  59521. public function __toString()
  59522. {
  59523. return $this->render();
  59524. }
  59525. public function render()
  59526. {
  59527. return $this->value->render();
  59528. }
  59529. public function renderPattern()
  59530. {
  59531. return $this->value->renderPattern();
  59532. }
  59533. public function isCaseSensitive()
  59534. {
  59535. return $this->value->isCaseSensitive();
  59536. }
  59537. public function getType()
  59538. {
  59539. return $this->value->getType();
  59540. }
  59541. public function prepend($expr)
  59542. {
  59543. $this->value->prepend($expr);
  59544. return $this;
  59545. }
  59546. public function append($expr)
  59547. {
  59548. $this->value->append($expr);
  59549. return $this;
  59550. }
  59551. public function isRegex()
  59552. {
  59553. return self::TYPE_REGEX === $this->value->getType();
  59554. }
  59555. public function isGlob()
  59556. {
  59557. return self::TYPE_GLOB === $this->value->getType();
  59558. }
  59559. public function getGlob()
  59560. {
  59561. if (self::TYPE_GLOB !== $this->value->getType()) {
  59562. throw new \LogicException('Regex can\'t be transformed to glob.');
  59563. }
  59564. return $this->value;
  59565. }
  59566. public function getRegex()
  59567. {
  59568. return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
  59569. }
  59570. }
  59571. <?php
  59572. namespace Symfony\Component\Finder\Expression;
  59573. @trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59574. use Symfony\Component\Finder\Glob as FinderGlob;
  59575. class Glob implements ValueInterface
  59576. {
  59577. private $pattern;
  59578. public function __construct($pattern)
  59579. {
  59580. $this->pattern = $pattern;
  59581. }
  59582. public function render()
  59583. {
  59584. return $this->pattern;
  59585. }
  59586. public function renderPattern()
  59587. {
  59588. return $this->pattern;
  59589. }
  59590. public function getType()
  59591. {
  59592. return Expression::TYPE_GLOB;
  59593. }
  59594. public function isCaseSensitive()
  59595. {
  59596. return true;
  59597. }
  59598. public function prepend($expr)
  59599. {
  59600. $this->pattern = $expr.$this->pattern;
  59601. return $this;
  59602. }
  59603. public function append($expr)
  59604. {
  59605. $this->pattern .= $expr;
  59606. return $this;
  59607. }
  59608. public function isExpandable()
  59609. {
  59610. return false !== strpos($this->pattern, '{')
  59611. && false !== strpos($this->pattern, '}');
  59612. }
  59613. public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
  59614. {
  59615. $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
  59616. return new Regex($regex);
  59617. }
  59618. }
  59619. <?php
  59620. namespace Symfony\Component\Finder\Expression;
  59621. @trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59622. class Regex implements ValueInterface
  59623. {
  59624. const START_FLAG = '^';
  59625. const END_FLAG = '$';
  59626. const BOUNDARY = '~';
  59627. const JOKER = '.*';
  59628. const ESCAPING = '\\';
  59629. private $pattern;
  59630. private $options;
  59631. private $startFlag;
  59632. private $endFlag;
  59633. private $startJoker;
  59634. private $endJoker;
  59635. public static function create($expr)
  59636. {
  59637. if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
  59638. $start = substr($m[1], 0, 1);
  59639. $end = substr($m[1], -1);
  59640. if (
  59641. ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
  59642. || ('{' === $start && '}' === $end)
  59643. || ('(' === $start && ')' === $end)
  59644. ) {
  59645. return new self(substr($m[1], 1, -1), $m[2], $end);
  59646. }
  59647. }
  59648. throw new \InvalidArgumentException('Given expression is not a regex.');
  59649. }
  59650. public function __construct($pattern, $options = '', $delimiter = null)
  59651. {
  59652. if (null !== $delimiter) {
  59653. $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
  59654. }
  59655. $this->parsePattern($pattern);
  59656. $this->options = $options;
  59657. }
  59658. public function __toString()
  59659. {
  59660. return $this->render();
  59661. }
  59662. public function render()
  59663. {
  59664. return self::BOUNDARY
  59665. .$this->renderPattern()
  59666. .self::BOUNDARY
  59667. .$this->options;
  59668. }
  59669. public function renderPattern()
  59670. {
  59671. return ($this->startFlag ? self::START_FLAG : '')
  59672. .($this->startJoker ? self::JOKER : '')
  59673. .str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
  59674. .($this->endJoker ? self::JOKER : '')
  59675. .($this->endFlag ? self::END_FLAG : '');
  59676. }
  59677. public function isCaseSensitive()
  59678. {
  59679. return !$this->hasOption('i');
  59680. }
  59681. public function getType()
  59682. {
  59683. return Expression::TYPE_REGEX;
  59684. }
  59685. public function prepend($expr)
  59686. {
  59687. $this->pattern = $expr.$this->pattern;
  59688. return $this;
  59689. }
  59690. public function append($expr)
  59691. {
  59692. $this->pattern .= $expr;
  59693. return $this;
  59694. }
  59695. public function hasOption($option)
  59696. {
  59697. return false !== strpos($this->options, $option);
  59698. }
  59699. public function addOption($option)
  59700. {
  59701. if (!$this->hasOption($option)) {
  59702. $this->options .= $option;
  59703. }
  59704. return $this;
  59705. }
  59706. public function removeOption($option)
  59707. {
  59708. $this->options = str_replace($option, '', $this->options);
  59709. return $this;
  59710. }
  59711. public function setStartFlag($startFlag)
  59712. {
  59713. $this->startFlag = $startFlag;
  59714. return $this;
  59715. }
  59716. public function hasStartFlag()
  59717. {
  59718. return $this->startFlag;
  59719. }
  59720. public function setEndFlag($endFlag)
  59721. {
  59722. $this->endFlag = (bool) $endFlag;
  59723. return $this;
  59724. }
  59725. public function hasEndFlag()
  59726. {
  59727. return $this->endFlag;
  59728. }
  59729. public function setStartJoker($startJoker)
  59730. {
  59731. $this->startJoker = $startJoker;
  59732. return $this;
  59733. }
  59734. public function hasStartJoker()
  59735. {
  59736. return $this->startJoker;
  59737. }
  59738. public function setEndJoker($endJoker)
  59739. {
  59740. $this->endJoker = (bool) $endJoker;
  59741. return $this;
  59742. }
  59743. public function hasEndJoker()
  59744. {
  59745. return $this->endJoker;
  59746. }
  59747. public function replaceJokers($replacement)
  59748. {
  59749. $replace = function ($subject) use ($replacement) {
  59750. $subject = $subject[0];
  59751. $replace = 0 === substr_count($subject, '\\') % 2;
  59752. return $replace ? str_replace('.', $replacement, $subject) : $subject;
  59753. };
  59754. $this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
  59755. return $this;
  59756. }
  59757. private function parsePattern($pattern)
  59758. {
  59759. if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
  59760. $pattern = substr($pattern, 1);
  59761. }
  59762. if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
  59763. $pattern = substr($pattern, 2);
  59764. }
  59765. if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
  59766. $pattern = substr($pattern, 0, -1);
  59767. }
  59768. if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
  59769. $pattern = substr($pattern, 0, -2);
  59770. }
  59771. $this->pattern = $pattern;
  59772. }
  59773. }
  59774. <?php
  59775. namespace Symfony\Component\Finder\Expression;
  59776. @trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59777. interface ValueInterface
  59778. {
  59779. public function render();
  59780. public function renderPattern();
  59781. public function isCaseSensitive();
  59782. public function getType();
  59783. public function prepend($expr);
  59784. public function append($expr);
  59785. }
  59786. <?php
  59787. namespace Symfony\Component\Finder;
  59788. use Symfony\Component\Finder\Adapter\AdapterInterface;
  59789. use Symfony\Component\Finder\Adapter\BsdFindAdapter;
  59790. use Symfony\Component\Finder\Adapter\GnuFindAdapter;
  59791. use Symfony\Component\Finder\Adapter\PhpAdapter;
  59792. use Symfony\Component\Finder\Comparator\DateComparator;
  59793. use Symfony\Component\Finder\Comparator\NumberComparator;
  59794. use Symfony\Component\Finder\Exception\ExceptionInterface;
  59795. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  59796. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  59797. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  59798. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  59799. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  59800. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  59801. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  59802. use Symfony\Component\Finder\Iterator\SortableIterator;
  59803. class Finder implements \IteratorAggregate, \Countable
  59804. {
  59805. const IGNORE_VCS_FILES = 1;
  59806. const IGNORE_DOT_FILES = 2;
  59807. private $mode = 0;
  59808. private $names = array();
  59809. private $notNames = array();
  59810. private $exclude = array();
  59811. private $filters = array();
  59812. private $depths = array();
  59813. private $sizes = array();
  59814. private $followLinks = false;
  59815. private $sort = false;
  59816. private $ignore = 0;
  59817. private $dirs = array();
  59818. private $dates = array();
  59819. private $iterators = array();
  59820. private $contains = array();
  59821. private $notContains = array();
  59822. private $adapters = null;
  59823. private $paths = array();
  59824. private $notPaths = array();
  59825. private $ignoreUnreadableDirs = false;
  59826. private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
  59827. public function __construct()
  59828. {
  59829. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  59830. }
  59831. public static function create()
  59832. {
  59833. return new static();
  59834. }
  59835. public function addAdapter(AdapterInterface $adapter, $priority = 0)
  59836. {
  59837. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59838. $this->initDefaultAdapters();
  59839. $this->adapters[$adapter->getName()] = array(
  59840. 'adapter' => $adapter,
  59841. 'priority' => $priority,
  59842. 'selected' => false,
  59843. );
  59844. return $this->sortAdapters();
  59845. }
  59846. public function useBestAdapter()
  59847. {
  59848. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59849. $this->initDefaultAdapters();
  59850. $this->resetAdapterSelection();
  59851. return $this->sortAdapters();
  59852. }
  59853. public function setAdapter($name)
  59854. {
  59855. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59856. $this->initDefaultAdapters();
  59857. if (!isset($this->adapters[$name])) {
  59858. throw new \InvalidArgumentException(sprintf('Adapter "%s" does not exist.', $name));
  59859. }
  59860. $this->resetAdapterSelection();
  59861. $this->adapters[$name]['selected'] = true;
  59862. return $this->sortAdapters();
  59863. }
  59864. public function removeAdapters()
  59865. {
  59866. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59867. $this->adapters = array();
  59868. return $this;
  59869. }
  59870. public function getAdapters()
  59871. {
  59872. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59873. $this->initDefaultAdapters();
  59874. return array_values(array_map(function (array $adapter) {
  59875. return $adapter['adapter'];
  59876. }, $this->adapters));
  59877. }
  59878. public function directories()
  59879. {
  59880. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  59881. return $this;
  59882. }
  59883. public function files()
  59884. {
  59885. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  59886. return $this;
  59887. }
  59888. public function depth($level)
  59889. {
  59890. $this->depths[] = new Comparator\NumberComparator($level);
  59891. return $this;
  59892. }
  59893. public function date($date)
  59894. {
  59895. $this->dates[] = new Comparator\DateComparator($date);
  59896. return $this;
  59897. }
  59898. public function name($pattern)
  59899. {
  59900. $this->names[] = $pattern;
  59901. return $this;
  59902. }
  59903. public function notName($pattern)
  59904. {
  59905. $this->notNames[] = $pattern;
  59906. return $this;
  59907. }
  59908. public function contains($pattern)
  59909. {
  59910. $this->contains[] = $pattern;
  59911. return $this;
  59912. }
  59913. public function notContains($pattern)
  59914. {
  59915. $this->notContains[] = $pattern;
  59916. return $this;
  59917. }
  59918. public function path($pattern)
  59919. {
  59920. $this->paths[] = $pattern;
  59921. return $this;
  59922. }
  59923. public function notPath($pattern)
  59924. {
  59925. $this->notPaths[] = $pattern;
  59926. return $this;
  59927. }
  59928. public function size($size)
  59929. {
  59930. $this->sizes[] = new Comparator\NumberComparator($size);
  59931. return $this;
  59932. }
  59933. public function exclude($dirs)
  59934. {
  59935. $this->exclude = array_merge($this->exclude, (array) $dirs);
  59936. return $this;
  59937. }
  59938. public function ignoreDotFiles($ignoreDotFiles)
  59939. {
  59940. if ($ignoreDotFiles) {
  59941. $this->ignore |= static::IGNORE_DOT_FILES;
  59942. } else {
  59943. $this->ignore &= ~static::IGNORE_DOT_FILES;
  59944. }
  59945. return $this;
  59946. }
  59947. public function ignoreVCS($ignoreVCS)
  59948. {
  59949. if ($ignoreVCS) {
  59950. $this->ignore |= static::IGNORE_VCS_FILES;
  59951. } else {
  59952. $this->ignore &= ~static::IGNORE_VCS_FILES;
  59953. }
  59954. return $this;
  59955. }
  59956. public static function addVCSPattern($pattern)
  59957. {
  59958. foreach ((array) $pattern as $p) {
  59959. self::$vcsPatterns[] = $p;
  59960. }
  59961. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  59962. }
  59963. public function sort(\Closure $closure)
  59964. {
  59965. $this->sort = $closure;
  59966. return $this;
  59967. }
  59968. public function sortByName()
  59969. {
  59970. $this->sort = Iterator\SortableIterator::SORT_BY_NAME;
  59971. return $this;
  59972. }
  59973. public function sortByType()
  59974. {
  59975. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  59976. return $this;
  59977. }
  59978. public function sortByAccessedTime()
  59979. {
  59980. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  59981. return $this;
  59982. }
  59983. public function sortByChangedTime()
  59984. {
  59985. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  59986. return $this;
  59987. }
  59988. public function sortByModifiedTime()
  59989. {
  59990. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  59991. return $this;
  59992. }
  59993. public function filter(\Closure $closure)
  59994. {
  59995. $this->filters[] = $closure;
  59996. return $this;
  59997. }
  59998. public function followLinks()
  59999. {
  60000. $this->followLinks = true;
  60001. return $this;
  60002. }
  60003. public function ignoreUnreadableDirs($ignore = true)
  60004. {
  60005. $this->ignoreUnreadableDirs = (bool) $ignore;
  60006. return $this;
  60007. }
  60008. public function in($dirs)
  60009. {
  60010. $resolvedDirs = array();
  60011. foreach ((array) $dirs as $dir) {
  60012. if (is_dir($dir)) {
  60013. $resolvedDirs[] = $this->normalizeDir($dir);
  60014. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
  60015. $resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
  60016. } else {
  60017. throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
  60018. }
  60019. }
  60020. $this->dirs = array_merge($this->dirs, $resolvedDirs);
  60021. return $this;
  60022. }
  60023. public function getIterator()
  60024. {
  60025. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  60026. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  60027. }
  60028. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  60029. return $this->searchInDirectory($this->dirs[0]);
  60030. }
  60031. $iterator = new \AppendIterator();
  60032. foreach ($this->dirs as $dir) {
  60033. $iterator->append($this->searchInDirectory($dir));
  60034. }
  60035. foreach ($this->iterators as $it) {
  60036. $iterator->append($it);
  60037. }
  60038. return $iterator;
  60039. }
  60040. public function append($iterator)
  60041. {
  60042. if ($iterator instanceof \IteratorAggregate) {
  60043. $this->iterators[] = $iterator->getIterator();
  60044. } elseif ($iterator instanceof \Iterator) {
  60045. $this->iterators[] = $iterator;
  60046. } elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
  60047. $it = new \ArrayIterator();
  60048. foreach ($iterator as $file) {
  60049. $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
  60050. }
  60051. $this->iterators[] = $it;
  60052. } else {
  60053. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  60054. }
  60055. return $this;
  60056. }
  60057. public function count()
  60058. {
  60059. return iterator_count($this->getIterator());
  60060. }
  60061. private function sortAdapters()
  60062. {
  60063. uasort($this->adapters, function (array $a, array $b) {
  60064. if ($a['selected'] || $b['selected']) {
  60065. return $a['selected'] ? -1 : 1;
  60066. }
  60067. return $a['priority'] > $b['priority'] ? -1 : 1;
  60068. });
  60069. return $this;
  60070. }
  60071. private function searchInDirectory($dir)
  60072. {
  60073. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  60074. $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  60075. }
  60076. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  60077. $this->notPaths[] = '#(^|/)\..+(/|$)#';
  60078. }
  60079. if ($this->adapters) {
  60080. foreach ($this->adapters as $adapter) {
  60081. if ($adapter['adapter']->isSupported()) {
  60082. try {
  60083. return $this
  60084. ->buildAdapter($adapter['adapter'])
  60085. ->searchInDirectory($dir);
  60086. } catch (ExceptionInterface $e) {
  60087. }
  60088. }
  60089. }
  60090. }
  60091. $minDepth = 0;
  60092. $maxDepth = PHP_INT_MAX;
  60093. foreach ($this->depths as $comparator) {
  60094. switch ($comparator->getOperator()) {
  60095. case '>':
  60096. $minDepth = $comparator->getTarget() + 1;
  60097. break;
  60098. case '>=':
  60099. $minDepth = $comparator->getTarget();
  60100. break;
  60101. case '<':
  60102. $maxDepth = $comparator->getTarget() - 1;
  60103. break;
  60104. case '<=':
  60105. $maxDepth = $comparator->getTarget();
  60106. break;
  60107. default:
  60108. $minDepth = $maxDepth = $comparator->getTarget();
  60109. }
  60110. }
  60111. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  60112. if ($this->followLinks) {
  60113. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  60114. }
  60115. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  60116. if ($this->exclude) {
  60117. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  60118. }
  60119. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  60120. if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
  60121. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  60122. }
  60123. if ($this->mode) {
  60124. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  60125. }
  60126. if ($this->names || $this->notNames) {
  60127. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  60128. }
  60129. if ($this->contains || $this->notContains) {
  60130. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  60131. }
  60132. if ($this->sizes) {
  60133. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  60134. }
  60135. if ($this->dates) {
  60136. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  60137. }
  60138. if ($this->filters) {
  60139. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  60140. }
  60141. if ($this->paths || $this->notPaths) {
  60142. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  60143. }
  60144. if ($this->sort) {
  60145. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  60146. $iterator = $iteratorAggregate->getIterator();
  60147. }
  60148. return $iterator;
  60149. }
  60150. private function buildAdapter(AdapterInterface $adapter)
  60151. {
  60152. return $adapter
  60153. ->setFollowLinks($this->followLinks)
  60154. ->setDepths($this->depths)
  60155. ->setMode($this->mode)
  60156. ->setExclude($this->exclude)
  60157. ->setNames($this->names)
  60158. ->setNotNames($this->notNames)
  60159. ->setContains($this->contains)
  60160. ->setNotContains($this->notContains)
  60161. ->setSizes($this->sizes)
  60162. ->setDates($this->dates)
  60163. ->setFilters($this->filters)
  60164. ->setSort($this->sort)
  60165. ->setPath($this->paths)
  60166. ->setNotPath($this->notPaths)
  60167. ->ignoreUnreadableDirs($this->ignoreUnreadableDirs);
  60168. }
  60169. private function resetAdapterSelection()
  60170. {
  60171. $this->adapters = array_map(function (array $properties) {
  60172. $properties['selected'] = false;
  60173. return $properties;
  60174. }, $this->adapters);
  60175. }
  60176. private function initDefaultAdapters()
  60177. {
  60178. if (null === $this->adapters) {
  60179. $this->adapters = array();
  60180. $this
  60181. ->addAdapter(new GnuFindAdapter())
  60182. ->addAdapter(new BsdFindAdapter())
  60183. ->addAdapter(new PhpAdapter(), -50)
  60184. ->setAdapter('php')
  60185. ;
  60186. }
  60187. }
  60188. private function normalizeDir($dir)
  60189. {
  60190. return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  60191. }
  60192. }
  60193. <?php
  60194. namespace Symfony\Component\Finder;
  60195. class Glob
  60196. {
  60197. public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
  60198. {
  60199. $firstByte = true;
  60200. $escaping = false;
  60201. $inCurlies = 0;
  60202. $regex = '';
  60203. $sizeGlob = \strlen($glob);
  60204. for ($i = 0; $i < $sizeGlob; ++$i) {
  60205. $car = $glob[$i];
  60206. if ($firstByte) {
  60207. if ($strictLeadingDot && '.' !== $car) {
  60208. $regex .= '(?=[^\.])';
  60209. }
  60210. $firstByte = false;
  60211. }
  60212. if ('/' === $car) {
  60213. $firstByte = true;
  60214. }
  60215. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  60216. $regex .= "\\$car";
  60217. } elseif ('*' === $car) {
  60218. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  60219. } elseif ('?' === $car) {
  60220. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  60221. } elseif ('{' === $car) {
  60222. $regex .= $escaping ? '\\{' : '(';
  60223. if (!$escaping) {
  60224. ++$inCurlies;
  60225. }
  60226. } elseif ('}' === $car && $inCurlies) {
  60227. $regex .= $escaping ? '}' : ')';
  60228. if (!$escaping) {
  60229. --$inCurlies;
  60230. }
  60231. } elseif (',' === $car && $inCurlies) {
  60232. $regex .= $escaping ? ',' : '|';
  60233. } elseif ('\\' === $car) {
  60234. if ($escaping) {
  60235. $regex .= '\\\\';
  60236. $escaping = false;
  60237. } else {
  60238. $escaping = true;
  60239. }
  60240. continue;
  60241. } else {
  60242. $regex .= $car;
  60243. }
  60244. $escaping = false;
  60245. }
  60246. return $delimiter.'^'.$regex.'$'.$delimiter;
  60247. }
  60248. }
  60249. <?php
  60250. namespace Symfony\Component\Finder\Iterator;
  60251. class CustomFilterIterator extends FilterIterator
  60252. {
  60253. private $filters = array();
  60254. public function __construct(\Iterator $iterator, array $filters)
  60255. {
  60256. foreach ($filters as $filter) {
  60257. if (!\is_callable($filter)) {
  60258. throw new \InvalidArgumentException('Invalid PHP callback.');
  60259. }
  60260. }
  60261. $this->filters = $filters;
  60262. parent::__construct($iterator);
  60263. }
  60264. public function accept()
  60265. {
  60266. $fileinfo = $this->current();
  60267. foreach ($this->filters as $filter) {
  60268. if (false === \call_user_func($filter, $fileinfo)) {
  60269. return false;
  60270. }
  60271. }
  60272. return true;
  60273. }
  60274. }
  60275. <?php
  60276. namespace Symfony\Component\Finder\Iterator;
  60277. use Symfony\Component\Finder\Comparator\DateComparator;
  60278. class DateRangeFilterIterator extends FilterIterator
  60279. {
  60280. private $comparators = array();
  60281. public function __construct(\Iterator $iterator, array $comparators)
  60282. {
  60283. $this->comparators = $comparators;
  60284. parent::__construct($iterator);
  60285. }
  60286. public function accept()
  60287. {
  60288. $fileinfo = $this->current();
  60289. if (!file_exists($fileinfo->getPathname())) {
  60290. return false;
  60291. }
  60292. $filedate = $fileinfo->getMTime();
  60293. foreach ($this->comparators as $compare) {
  60294. if (!$compare->test($filedate)) {
  60295. return false;
  60296. }
  60297. }
  60298. return true;
  60299. }
  60300. }
  60301. <?php
  60302. namespace Symfony\Component\Finder\Iterator;
  60303. class DepthRangeFilterIterator extends FilterIterator
  60304. {
  60305. private $minDepth = 0;
  60306. public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
  60307. {
  60308. $this->minDepth = $minDepth;
  60309. $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  60310. parent::__construct($iterator);
  60311. }
  60312. public function accept()
  60313. {
  60314. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  60315. }
  60316. }
  60317. <?php
  60318. namespace Symfony\Component\Finder\Iterator;
  60319. class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
  60320. {
  60321. private $iterator;
  60322. private $isRecursive;
  60323. private $excludedDirs = array();
  60324. private $excludedPattern;
  60325. public function __construct(\Iterator $iterator, array $directories)
  60326. {
  60327. $this->iterator = $iterator;
  60328. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  60329. $patterns = array();
  60330. foreach ($directories as $directory) {
  60331. $directory = rtrim($directory, '/');
  60332. if (!$this->isRecursive || false !== strpos($directory, '/')) {
  60333. $patterns[] = preg_quote($directory, '#');
  60334. } else {
  60335. $this->excludedDirs[$directory] = true;
  60336. }
  60337. }
  60338. if ($patterns) {
  60339. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  60340. }
  60341. parent::__construct($iterator);
  60342. }
  60343. public function accept()
  60344. {
  60345. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  60346. return false;
  60347. }
  60348. if ($this->excludedPattern) {
  60349. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  60350. $path = str_replace('\\', '/', $path);
  60351. return !preg_match($this->excludedPattern, $path);
  60352. }
  60353. return true;
  60354. }
  60355. public function hasChildren()
  60356. {
  60357. return $this->isRecursive && $this->iterator->hasChildren();
  60358. }
  60359. public function getChildren()
  60360. {
  60361. $children = new self($this->iterator->getChildren(), array());
  60362. $children->excludedDirs = $this->excludedDirs;
  60363. $children->excludedPattern = $this->excludedPattern;
  60364. return $children;
  60365. }
  60366. }
  60367. <?php
  60368. namespace Symfony\Component\Finder\Iterator;
  60369. @trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  60370. use Symfony\Component\Finder\SplFileInfo;
  60371. class FilePathsIterator extends \ArrayIterator
  60372. {
  60373. private $baseDir;
  60374. private $baseDirLength;
  60375. private $subPath;
  60376. private $subPathname;
  60377. private $current;
  60378. public function __construct(array $paths, $baseDir)
  60379. {
  60380. $this->baseDir = $baseDir;
  60381. $this->baseDirLength = \strlen($baseDir);
  60382. parent::__construct($paths);
  60383. }
  60384. public function __call($name, array $arguments)
  60385. {
  60386. return \call_user_func_array(array($this->current(), $name), $arguments);
  60387. }
  60388. public function current()
  60389. {
  60390. return $this->current;
  60391. }
  60392. public function key()
  60393. {
  60394. return $this->current->getPathname();
  60395. }
  60396. public function next()
  60397. {
  60398. parent::next();
  60399. $this->buildProperties();
  60400. }
  60401. public function rewind()
  60402. {
  60403. parent::rewind();
  60404. $this->buildProperties();
  60405. }
  60406. public function getSubPath()
  60407. {
  60408. return $this->subPath;
  60409. }
  60410. public function getSubPathname()
  60411. {
  60412. return $this->subPathname;
  60413. }
  60414. private function buildProperties()
  60415. {
  60416. $absolutePath = parent::current();
  60417. if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
  60418. $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
  60419. $dir = \dirname($this->subPathname);
  60420. $this->subPath = '.' === $dir ? '' : $dir;
  60421. } else {
  60422. $this->subPath = $this->subPathname = '';
  60423. }
  60424. $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
  60425. }
  60426. }
  60427. <?php
  60428. namespace Symfony\Component\Finder\Iterator;
  60429. class FileTypeFilterIterator extends FilterIterator
  60430. {
  60431. const ONLY_FILES = 1;
  60432. const ONLY_DIRECTORIES = 2;
  60433. private $mode;
  60434. public function __construct(\Iterator $iterator, $mode)
  60435. {
  60436. $this->mode = $mode;
  60437. parent::__construct($iterator);
  60438. }
  60439. public function accept()
  60440. {
  60441. $fileinfo = $this->current();
  60442. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  60443. return false;
  60444. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  60445. return false;
  60446. }
  60447. return true;
  60448. }
  60449. }
  60450. <?php
  60451. namespace Symfony\Component\Finder\Iterator;
  60452. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  60453. {
  60454. public function accept()
  60455. {
  60456. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  60457. return true;
  60458. }
  60459. $fileinfo = $this->current();
  60460. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  60461. return false;
  60462. }
  60463. $content = $fileinfo->getContents();
  60464. if (!$content) {
  60465. return false;
  60466. }
  60467. return $this->isAccepted($content);
  60468. }
  60469. protected function toRegex($str)
  60470. {
  60471. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  60472. }
  60473. }
  60474. <?php
  60475. namespace Symfony\Component\Finder\Iterator;
  60476. use Symfony\Component\Finder\Glob;
  60477. class FilenameFilterIterator extends MultiplePcreFilterIterator
  60478. {
  60479. public function accept()
  60480. {
  60481. return $this->isAccepted($this->current()->getFilename());
  60482. }
  60483. protected function toRegex($str)
  60484. {
  60485. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  60486. }
  60487. }
  60488. <?php
  60489. namespace Symfony\Component\Finder\Iterator;
  60490. abstract class FilterIterator extends \FilterIterator
  60491. {
  60492. public function rewind()
  60493. {
  60494. if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
  60495. parent::rewind();
  60496. return;
  60497. }
  60498. $iterator = $this;
  60499. while ($iterator instanceof \OuterIterator) {
  60500. $innerIterator = $iterator->getInnerIterator();
  60501. if ($innerIterator instanceof RecursiveDirectoryIterator) {
  60502. if ($innerIterator->isRewindable()) {
  60503. $innerIterator->next();
  60504. $innerIterator->rewind();
  60505. }
  60506. } elseif ($innerIterator instanceof \FilesystemIterator) {
  60507. $innerIterator->next();
  60508. $innerIterator->rewind();
  60509. }
  60510. $iterator = $innerIterator;
  60511. }
  60512. parent::rewind();
  60513. }
  60514. }
  60515. <?php
  60516. namespace Symfony\Component\Finder\Iterator;
  60517. abstract class MultiplePcreFilterIterator extends FilterIterator
  60518. {
  60519. protected $matchRegexps = array();
  60520. protected $noMatchRegexps = array();
  60521. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  60522. {
  60523. foreach ($matchPatterns as $pattern) {
  60524. $this->matchRegexps[] = $this->toRegex($pattern);
  60525. }
  60526. foreach ($noMatchPatterns as $pattern) {
  60527. $this->noMatchRegexps[] = $this->toRegex($pattern);
  60528. }
  60529. parent::__construct($iterator);
  60530. }
  60531. protected function isAccepted($string)
  60532. {
  60533. foreach ($this->noMatchRegexps as $regex) {
  60534. if (preg_match($regex, $string)) {
  60535. return false;
  60536. }
  60537. }
  60538. if ($this->matchRegexps) {
  60539. foreach ($this->matchRegexps as $regex) {
  60540. if (preg_match($regex, $string)) {
  60541. return true;
  60542. }
  60543. }
  60544. return false;
  60545. }
  60546. return true;
  60547. }
  60548. protected function isRegex($str)
  60549. {
  60550. if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
  60551. $start = substr($m[1], 0, 1);
  60552. $end = substr($m[1], -1);
  60553. if ($start === $end) {
  60554. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  60555. }
  60556. foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
  60557. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  60558. return true;
  60559. }
  60560. }
  60561. }
  60562. return false;
  60563. }
  60564. abstract protected function toRegex($str);
  60565. }
  60566. <?php
  60567. namespace Symfony\Component\Finder\Iterator;
  60568. class PathFilterIterator extends MultiplePcreFilterIterator
  60569. {
  60570. public function accept()
  60571. {
  60572. $filename = $this->current()->getRelativePathname();
  60573. if ('\\' === \DIRECTORY_SEPARATOR) {
  60574. $filename = str_replace('\\', '/', $filename);
  60575. }
  60576. return $this->isAccepted($filename);
  60577. }
  60578. protected function toRegex($str)
  60579. {
  60580. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  60581. }
  60582. }
  60583. <?php
  60584. namespace Symfony\Component\Finder\Iterator;
  60585. use Symfony\Component\Finder\Exception\AccessDeniedException;
  60586. use Symfony\Component\Finder\SplFileInfo;
  60587. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  60588. {
  60589. private $ignoreUnreadableDirs;
  60590. private $rewindable;
  60591. private $rootPath;
  60592. private $subPath;
  60593. private $directorySeparator = '/';
  60594. public function __construct($path, $flags, $ignoreUnreadableDirs = false)
  60595. {
  60596. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  60597. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  60598. }
  60599. parent::__construct($path, $flags);
  60600. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  60601. $this->rootPath = (string) $path;
  60602. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  60603. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  60604. }
  60605. }
  60606. public function current()
  60607. {
  60608. if (null === $subPathname = $this->subPath) {
  60609. $subPathname = $this->subPath = (string) $this->getSubPath();
  60610. }
  60611. if ('' !== $subPathname) {
  60612. $subPathname .= $this->directorySeparator;
  60613. }
  60614. $subPathname .= $this->getFilename();
  60615. return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
  60616. }
  60617. public function getChildren()
  60618. {
  60619. try {
  60620. $children = parent::getChildren();
  60621. if ($children instanceof self) {
  60622. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  60623. $children->rewindable = &$this->rewindable;
  60624. $children->rootPath = $this->rootPath;
  60625. }
  60626. return $children;
  60627. } catch (\UnexpectedValueException $e) {
  60628. if ($this->ignoreUnreadableDirs) {
  60629. return new \RecursiveArrayIterator(array());
  60630. } else {
  60631. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  60632. }
  60633. }
  60634. }
  60635. public function rewind()
  60636. {
  60637. if (false === $this->isRewindable()) {
  60638. return;
  60639. }
  60640. if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
  60641. parent::next();
  60642. }
  60643. parent::rewind();
  60644. }
  60645. public function isRewindable()
  60646. {
  60647. if (null !== $this->rewindable) {
  60648. return $this->rewindable;
  60649. }
  60650. if ('' === $this->getPath()) {
  60651. return $this->rewindable = false;
  60652. }
  60653. if (false !== $stream = @opendir($this->getPath())) {
  60654. $infos = stream_get_meta_data($stream);
  60655. closedir($stream);
  60656. if ($infos['seekable']) {
  60657. return $this->rewindable = true;
  60658. }
  60659. }
  60660. return $this->rewindable = false;
  60661. }
  60662. }
  60663. <?php
  60664. namespace Symfony\Component\Finder\Iterator;
  60665. use Symfony\Component\Finder\Comparator\NumberComparator;
  60666. class SizeRangeFilterIterator extends FilterIterator
  60667. {
  60668. private $comparators = array();
  60669. public function __construct(\Iterator $iterator, array $comparators)
  60670. {
  60671. $this->comparators = $comparators;
  60672. parent::__construct($iterator);
  60673. }
  60674. public function accept()
  60675. {
  60676. $fileinfo = $this->current();
  60677. if (!$fileinfo->isFile()) {
  60678. return true;
  60679. }
  60680. $filesize = $fileinfo->getSize();
  60681. foreach ($this->comparators as $compare) {
  60682. if (!$compare->test($filesize)) {
  60683. return false;
  60684. }
  60685. }
  60686. return true;
  60687. }
  60688. }
  60689. <?php
  60690. namespace Symfony\Component\Finder\Iterator;
  60691. class SortableIterator implements \IteratorAggregate
  60692. {
  60693. const SORT_BY_NAME = 1;
  60694. const SORT_BY_TYPE = 2;
  60695. const SORT_BY_ACCESSED_TIME = 3;
  60696. const SORT_BY_CHANGED_TIME = 4;
  60697. const SORT_BY_MODIFIED_TIME = 5;
  60698. private $iterator;
  60699. private $sort;
  60700. public function __construct(\Traversable $iterator, $sort)
  60701. {
  60702. $this->iterator = $iterator;
  60703. if (self::SORT_BY_NAME === $sort) {
  60704. $this->sort = function ($a, $b) {
  60705. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  60706. };
  60707. } elseif (self::SORT_BY_TYPE === $sort) {
  60708. $this->sort = function ($a, $b) {
  60709. if ($a->isDir() && $b->isFile()) {
  60710. return -1;
  60711. } elseif ($a->isFile() && $b->isDir()) {
  60712. return 1;
  60713. }
  60714. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  60715. };
  60716. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  60717. $this->sort = function ($a, $b) {
  60718. return $a->getATime() - $b->getATime();
  60719. };
  60720. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  60721. $this->sort = function ($a, $b) {
  60722. return $a->getCTime() - $b->getCTime();
  60723. };
  60724. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  60725. $this->sort = function ($a, $b) {
  60726. return $a->getMTime() - $b->getMTime();
  60727. };
  60728. } elseif (\is_callable($sort)) {
  60729. $this->sort = $sort;
  60730. } else {
  60731. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  60732. }
  60733. }
  60734. public function getIterator()
  60735. {
  60736. $array = iterator_to_array($this->iterator, true);
  60737. uasort($array, $this->sort);
  60738. return new \ArrayIterator($array);
  60739. }
  60740. }
  60741. Copyright (c) 2004-2018 Fabien Potencier
  60742. Permission is hereby granted, free of charge, to any person obtaining a copy
  60743. of this software and associated documentation files (the "Software"), to deal
  60744. in the Software without restriction, including without limitation the rights
  60745. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  60746. copies of the Software, and to permit persons to whom the Software is furnished
  60747. to do so, subject to the following conditions:
  60748. The above copyright notice and this permission notice shall be included in all
  60749. copies or substantial portions of the Software.
  60750. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  60751. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  60752. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  60753. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  60754. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  60755. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  60756. THE SOFTWARE.
  60757. <?php
  60758. namespace Symfony\Component\Finder\Shell;
  60759. @trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  60760. class Command
  60761. {
  60762. private $parent;
  60763. private $bits = array();
  60764. private $labels = array();
  60765. private $errorHandler;
  60766. public function __construct(Command $parent = null)
  60767. {
  60768. $this->parent = $parent;
  60769. }
  60770. public function __toString()
  60771. {
  60772. return $this->join();
  60773. }
  60774. public static function create(Command $parent = null)
  60775. {
  60776. return new self($parent);
  60777. }
  60778. public static function escape($input)
  60779. {
  60780. return escapeshellcmd($input);
  60781. }
  60782. public static function quote($input)
  60783. {
  60784. return escapeshellarg($input);
  60785. }
  60786. public function add($bit)
  60787. {
  60788. $this->bits[] = $bit;
  60789. return $this;
  60790. }
  60791. public function top($bit)
  60792. {
  60793. array_unshift($this->bits, $bit);
  60794. foreach ($this->labels as $label => $index) {
  60795. ++$this->labels[$label];
  60796. }
  60797. return $this;
  60798. }
  60799. public function arg($arg)
  60800. {
  60801. $this->bits[] = self::quote($arg);
  60802. return $this;
  60803. }
  60804. public function cmd($esc)
  60805. {
  60806. $this->bits[] = self::escape($esc);
  60807. return $this;
  60808. }
  60809. public function ins($label)
  60810. {
  60811. if (isset($this->labels[$label])) {
  60812. throw new \RuntimeException(sprintf('Label "%s" already exists.', $label));
  60813. }
  60814. $this->bits[] = self::create($this);
  60815. $this->labels[$label] = \count($this->bits) - 1;
  60816. return $this->bits[$this->labels[$label]];
  60817. }
  60818. public function get($label)
  60819. {
  60820. if (!isset($this->labels[$label])) {
  60821. throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label));
  60822. }
  60823. return $this->bits[$this->labels[$label]];
  60824. }
  60825. public function end()
  60826. {
  60827. if (null === $this->parent) {
  60828. throw new \RuntimeException('Calling end on root command doesn\'t make sense.');
  60829. }
  60830. return $this->parent;
  60831. }
  60832. public function length()
  60833. {
  60834. return \count($this->bits);
  60835. }
  60836. public function setErrorHandler(\Closure $errorHandler)
  60837. {
  60838. $this->errorHandler = $errorHandler;
  60839. return $this;
  60840. }
  60841. public function getErrorHandler()
  60842. {
  60843. return $this->errorHandler;
  60844. }
  60845. public function execute()
  60846. {
  60847. if (null === $errorHandler = $this->errorHandler) {
  60848. exec($this->join(), $output);
  60849. } else {
  60850. $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
  60851. $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
  60852. if ($error = stream_get_contents($pipes[2])) {
  60853. $errorHandler($error);
  60854. }
  60855. proc_close($process);
  60856. }
  60857. return $output ?: array();
  60858. }
  60859. public function join()
  60860. {
  60861. return implode(' ', array_filter(
  60862. array_map(function ($bit) {
  60863. return $bit instanceof Command ? $bit->join() : ($bit ?: null);
  60864. }, $this->bits),
  60865. function ($bit) { return null !== $bit; }
  60866. ));
  60867. }
  60868. public function addAtIndex($bit, $index)
  60869. {
  60870. array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
  60871. return $this;
  60872. }
  60873. }
  60874. <?php
  60875. namespace Symfony\Component\Finder\Shell;
  60876. @trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  60877. class Shell
  60878. {
  60879. const TYPE_UNIX = 1;
  60880. const TYPE_DARWIN = 2;
  60881. const TYPE_CYGWIN = 3;
  60882. const TYPE_WINDOWS = 4;
  60883. const TYPE_BSD = 5;
  60884. private $type;
  60885. public function getType()
  60886. {
  60887. if (null === $this->type) {
  60888. $this->type = $this->guessType();
  60889. }
  60890. return $this->type;
  60891. }
  60892. public function testCommand($command)
  60893. {
  60894. if (!\function_exists('exec')) {
  60895. return false;
  60896. }
  60897. $testCommand = 'which ';
  60898. if (self::TYPE_WINDOWS === $this->type) {
  60899. $testCommand = 'where ';
  60900. }
  60901. $command = escapeshellcmd($command);
  60902. exec($testCommand.$command, $output, $code);
  60903. return 0 === $code && \count($output) > 0;
  60904. }
  60905. private function guessType()
  60906. {
  60907. $os = strtolower(PHP_OS);
  60908. if (false !== strpos($os, 'cygwin')) {
  60909. return self::TYPE_CYGWIN;
  60910. }
  60911. if (false !== strpos($os, 'darwin')) {
  60912. return self::TYPE_DARWIN;
  60913. }
  60914. if (false !== strpos($os, 'bsd')) {
  60915. return self::TYPE_BSD;
  60916. }
  60917. if (0 === strpos($os, 'win')) {
  60918. return self::TYPE_WINDOWS;
  60919. }
  60920. return self::TYPE_UNIX;
  60921. }
  60922. }
  60923. <?php
  60924. namespace Symfony\Component\Finder;
  60925. class SplFileInfo extends \SplFileInfo
  60926. {
  60927. private $relativePath;
  60928. private $relativePathname;
  60929. public function __construct($file, $relativePath, $relativePathname)
  60930. {
  60931. parent::__construct($file);
  60932. $this->relativePath = $relativePath;
  60933. $this->relativePathname = $relativePathname;
  60934. }
  60935. public function getRelativePath()
  60936. {
  60937. return $this->relativePath;
  60938. }
  60939. public function getRelativePathname()
  60940. {
  60941. return $this->relativePathname;
  60942. }
  60943. public function getContents()
  60944. {
  60945. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  60946. $content = file_get_contents($this->getPathname());
  60947. restore_error_handler();
  60948. if (false === $content) {
  60949. throw new \RuntimeException($error);
  60950. }
  60951. return $content;
  60952. }
  60953. }
  60954. <?php
  60955. namespace Symfony\Polyfill\Ctype;
  60956. final class Ctype
  60957. {
  60958. public static function ctype_alnum($text)
  60959. {
  60960. $text = self::convert_int_to_char_for_ctype($text);
  60961. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  60962. }
  60963. public static function ctype_alpha($text)
  60964. {
  60965. $text = self::convert_int_to_char_for_ctype($text);
  60966. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  60967. }
  60968. public static function ctype_cntrl($text)
  60969. {
  60970. $text = self::convert_int_to_char_for_ctype($text);
  60971. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  60972. }
  60973. public static function ctype_digit($text)
  60974. {
  60975. $text = self::convert_int_to_char_for_ctype($text);
  60976. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  60977. }
  60978. public static function ctype_graph($text)
  60979. {
  60980. $text = self::convert_int_to_char_for_ctype($text);
  60981. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  60982. }
  60983. public static function ctype_lower($text)
  60984. {
  60985. $text = self::convert_int_to_char_for_ctype($text);
  60986. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  60987. }
  60988. public static function ctype_print($text)
  60989. {
  60990. $text = self::convert_int_to_char_for_ctype($text);
  60991. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  60992. }
  60993. public static function ctype_punct($text)
  60994. {
  60995. $text = self::convert_int_to_char_for_ctype($text);
  60996. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  60997. }
  60998. public static function ctype_space($text)
  60999. {
  61000. $text = self::convert_int_to_char_for_ctype($text);
  61001. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  61002. }
  61003. public static function ctype_upper($text)
  61004. {
  61005. $text = self::convert_int_to_char_for_ctype($text);
  61006. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  61007. }
  61008. public static function ctype_xdigit($text)
  61009. {
  61010. $text = self::convert_int_to_char_for_ctype($text);
  61011. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  61012. }
  61013. private static function convert_int_to_char_for_ctype($int)
  61014. {
  61015. if (!\is_int($int)) {
  61016. return $int;
  61017. }
  61018. if ($int < -128 || $int > 255) {
  61019. return (string) $int;
  61020. }
  61021. if ($int < 0) {
  61022. $int += 256;
  61023. }
  61024. return \chr($int);
  61025. }
  61026. }
  61027. Copyright (c) 2018-2019 Fabien Potencier
  61028. Permission is hereby granted, free of charge, to any person obtaining a copy
  61029. of this software and associated documentation files (the "Software"), to deal
  61030. in the Software without restriction, including without limitation the rights
  61031. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  61032. copies of the Software, and to permit persons to whom the Software is furnished
  61033. to do so, subject to the following conditions:
  61034. The above copyright notice and this permission notice shall be included in all
  61035. copies or substantial portions of the Software.
  61036. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  61037. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  61038. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  61039. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  61040. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  61041. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  61042. THE SOFTWARE.
  61043. <?php
  61044. use Symfony\Polyfill\Ctype as p;
  61045. if (!function_exists('ctype_alnum')) {
  61046. function ctype_alnum($input) { return p\Ctype::ctype_alnum($input); }
  61047. }
  61048. if (!function_exists('ctype_alpha')) {
  61049. function ctype_alpha($input) { return p\Ctype::ctype_alpha($input); }
  61050. }
  61051. if (!function_exists('ctype_cntrl')) {
  61052. function ctype_cntrl($input) { return p\Ctype::ctype_cntrl($input); }
  61053. }
  61054. if (!function_exists('ctype_digit')) {
  61055. function ctype_digit($input) { return p\Ctype::ctype_digit($input); }
  61056. }
  61057. if (!function_exists('ctype_graph')) {
  61058. function ctype_graph($input) { return p\Ctype::ctype_graph($input); }
  61059. }
  61060. if (!function_exists('ctype_lower')) {
  61061. function ctype_lower($input) { return p\Ctype::ctype_lower($input); }
  61062. }
  61063. if (!function_exists('ctype_print')) {
  61064. function ctype_print($input) { return p\Ctype::ctype_print($input); }
  61065. }
  61066. if (!function_exists('ctype_punct')) {
  61067. function ctype_punct($input) { return p\Ctype::ctype_punct($input); }
  61068. }
  61069. if (!function_exists('ctype_space')) {
  61070. function ctype_space($input) { return p\Ctype::ctype_space($input); }
  61071. }
  61072. if (!function_exists('ctype_upper')) {
  61073. function ctype_upper($input) { return p\Ctype::ctype_upper($input); }
  61074. }
  61075. if (!function_exists('ctype_xdigit')) {
  61076. function ctype_xdigit($input) { return p\Ctype::ctype_xdigit($input); }
  61077. }
  61078. Copyright (c) 2015-2019 Fabien Potencier
  61079. Permission is hereby granted, free of charge, to any person obtaining a copy
  61080. of this software and associated documentation files (the "Software"), to deal
  61081. in the Software without restriction, including without limitation the rights
  61082. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  61083. copies of the Software, and to permit persons to whom the Software is furnished
  61084. to do so, subject to the following conditions:
  61085. The above copyright notice and this permission notice shall be included in all
  61086. copies or substantial portions of the Software.
  61087. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  61088. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  61089. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  61090. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  61091. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  61092. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  61093. THE SOFTWARE.
  61094. <?php
  61095. namespace Symfony\Polyfill\Mbstring;
  61096. final class Mbstring
  61097. {
  61098. const MB_CASE_FOLD = PHP_INT_MAX;
  61099. private static $encodingList = array('ASCII', 'UTF-8');
  61100. private static $language = 'neutral';
  61101. private static $internalEncoding = 'UTF-8';
  61102. private static $caseFold = array(
  61103. array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
  61104. array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'),
  61105. );
  61106. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  61107. {
  61108. if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
  61109. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  61110. } else {
  61111. $fromEncoding = self::getEncoding($fromEncoding);
  61112. }
  61113. $toEncoding = self::getEncoding($toEncoding);
  61114. if ('BASE64' === $fromEncoding) {
  61115. $s = base64_decode($s);
  61116. $fromEncoding = $toEncoding;
  61117. }
  61118. if ('BASE64' === $toEncoding) {
  61119. return base64_encode($s);
  61120. }
  61121. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  61122. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  61123. $fromEncoding = 'Windows-1252';
  61124. }
  61125. if ('UTF-8' !== $fromEncoding) {
  61126. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  61127. }
  61128. return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
  61129. }
  61130. if ('HTML-ENTITIES' === $fromEncoding) {
  61131. $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
  61132. $fromEncoding = 'UTF-8';
  61133. }
  61134. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  61135. }
  61136. public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
  61137. {
  61138. $vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
  61139. $ok = true;
  61140. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  61141. if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  61142. $ok = false;
  61143. }
  61144. });
  61145. return $ok ? $fromEncoding : false;
  61146. }
  61147. public static function mb_decode_mimeheader($s)
  61148. {
  61149. return iconv_mime_decode($s, 2, self::$internalEncoding);
  61150. }
  61151. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  61152. {
  61153. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
  61154. }
  61155. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  61156. {
  61157. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  61158. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  61159. return null;
  61160. }
  61161. if (!\is_array($convmap) || !$convmap) {
  61162. return false;
  61163. }
  61164. if (null !== $encoding && !\is_scalar($encoding)) {
  61165. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  61166. return '';
  61167. }
  61168. $s = (string) $s;
  61169. if ('' === $s) {
  61170. return '';
  61171. }
  61172. $encoding = self::getEncoding($encoding);
  61173. if ('UTF-8' === $encoding) {
  61174. $encoding = null;
  61175. if (!preg_match('//u', $s)) {
  61176. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  61177. }
  61178. } else {
  61179. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  61180. }
  61181. $cnt = floor(\count($convmap) / 4) * 4;
  61182. for ($i = 0; $i < $cnt; $i += 4) {
  61183. $convmap[$i] += $convmap[$i + 2];
  61184. $convmap[$i + 1] += $convmap[$i + 2];
  61185. }
  61186. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  61187. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  61188. for ($i = 0; $i < $cnt; $i += 4) {
  61189. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  61190. return Mbstring::mb_chr($c - $convmap[$i + 2]);
  61191. }
  61192. }
  61193. return $m[0];
  61194. }, $s);
  61195. if (null === $encoding) {
  61196. return $s;
  61197. }
  61198. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  61199. }
  61200. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  61201. {
  61202. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  61203. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  61204. return null;
  61205. }
  61206. if (!\is_array($convmap) || !$convmap) {
  61207. return false;
  61208. }
  61209. if (null !== $encoding && !\is_scalar($encoding)) {
  61210. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  61211. return null;
  61212. }
  61213. if (null !== $is_hex && !\is_scalar($is_hex)) {
  61214. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
  61215. return null;
  61216. }
  61217. $s = (string) $s;
  61218. if ('' === $s) {
  61219. return '';
  61220. }
  61221. $encoding = self::getEncoding($encoding);
  61222. if ('UTF-8' === $encoding) {
  61223. $encoding = null;
  61224. if (!preg_match('//u', $s)) {
  61225. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  61226. }
  61227. } else {
  61228. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  61229. }
  61230. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  61231. $cnt = floor(\count($convmap) / 4) * 4;
  61232. $i = 0;
  61233. $len = \strlen($s);
  61234. $result = '';
  61235. while ($i < $len) {
  61236. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  61237. $uchr = substr($s, $i, $ulen);
  61238. $i += $ulen;
  61239. $c = self::mb_ord($uchr);
  61240. for ($j = 0; $j < $cnt; $j += 4) {
  61241. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  61242. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  61243. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  61244. continue 2;
  61245. }
  61246. }
  61247. $result .= $uchr;
  61248. }
  61249. if (null === $encoding) {
  61250. return $result;
  61251. }
  61252. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  61253. }
  61254. public static function mb_convert_case($s, $mode, $encoding = null)
  61255. {
  61256. $s = (string) $s;
  61257. if ('' === $s) {
  61258. return '';
  61259. }
  61260. $encoding = self::getEncoding($encoding);
  61261. if ('UTF-8' === $encoding) {
  61262. $encoding = null;
  61263. if (!preg_match('//u', $s)) {
  61264. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  61265. }
  61266. } else {
  61267. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  61268. }
  61269. if (MB_CASE_TITLE == $mode) {
  61270. static $titleRegexp = null;
  61271. if (null === $titleRegexp) {
  61272. $titleRegexp = self::getData('titleCaseRegexp');
  61273. }
  61274. $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
  61275. } else {
  61276. if (MB_CASE_UPPER == $mode) {
  61277. static $upper = null;
  61278. if (null === $upper) {
  61279. $upper = self::getData('upperCase');
  61280. }
  61281. $map = $upper;
  61282. } else {
  61283. if (self::MB_CASE_FOLD === $mode) {
  61284. $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
  61285. }
  61286. static $lower = null;
  61287. if (null === $lower) {
  61288. $lower = self::getData('lowerCase');
  61289. }
  61290. $map = $lower;
  61291. }
  61292. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  61293. $i = 0;
  61294. $len = \strlen($s);
  61295. while ($i < $len) {
  61296. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  61297. $uchr = substr($s, $i, $ulen);
  61298. $i += $ulen;
  61299. if (isset($map[$uchr])) {
  61300. $uchr = $map[$uchr];
  61301. $nlen = \strlen($uchr);
  61302. if ($nlen == $ulen) {
  61303. $nlen = $i;
  61304. do {
  61305. $s[--$nlen] = $uchr[--$ulen];
  61306. } while ($ulen);
  61307. } else {
  61308. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  61309. $len += $nlen - $ulen;
  61310. $i += $nlen - $ulen;
  61311. }
  61312. }
  61313. }
  61314. }
  61315. if (null === $encoding) {
  61316. return $s;
  61317. }
  61318. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  61319. }
  61320. public static function mb_internal_encoding($encoding = null)
  61321. {
  61322. if (null === $encoding) {
  61323. return self::$internalEncoding;
  61324. }
  61325. $encoding = self::getEncoding($encoding);
  61326. if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
  61327. self::$internalEncoding = $encoding;
  61328. return true;
  61329. }
  61330. return false;
  61331. }
  61332. public static function mb_language($lang = null)
  61333. {
  61334. if (null === $lang) {
  61335. return self::$language;
  61336. }
  61337. switch ($lang = strtolower($lang)) {
  61338. case 'uni':
  61339. case 'neutral':
  61340. self::$language = $lang;
  61341. return true;
  61342. }
  61343. return false;
  61344. }
  61345. public static function mb_list_encodings()
  61346. {
  61347. return array('UTF-8');
  61348. }
  61349. public static function mb_encoding_aliases($encoding)
  61350. {
  61351. switch (strtoupper($encoding)) {
  61352. case 'UTF8':
  61353. case 'UTF-8':
  61354. return array('utf8');
  61355. }
  61356. return false;
  61357. }
  61358. public static function mb_check_encoding($var = null, $encoding = null)
  61359. {
  61360. if (null === $encoding) {
  61361. if (null === $var) {
  61362. return false;
  61363. }
  61364. $encoding = self::$internalEncoding;
  61365. }
  61366. return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
  61367. }
  61368. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  61369. {
  61370. if (null === $encodingList) {
  61371. $encodingList = self::$encodingList;
  61372. } else {
  61373. if (!\is_array($encodingList)) {
  61374. $encodingList = array_map('trim', explode(',', $encodingList));
  61375. }
  61376. $encodingList = array_map('strtoupper', $encodingList);
  61377. }
  61378. foreach ($encodingList as $enc) {
  61379. switch ($enc) {
  61380. case 'ASCII':
  61381. if (!preg_match('/[\x80-\xFF]/', $str)) {
  61382. return $enc;
  61383. }
  61384. break;
  61385. case 'UTF8':
  61386. case 'UTF-8':
  61387. if (preg_match('//u', $str)) {
  61388. return 'UTF-8';
  61389. }
  61390. break;
  61391. default:
  61392. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  61393. return $enc;
  61394. }
  61395. }
  61396. }
  61397. return false;
  61398. }
  61399. public static function mb_detect_order($encodingList = null)
  61400. {
  61401. if (null === $encodingList) {
  61402. return self::$encodingList;
  61403. }
  61404. if (!\is_array($encodingList)) {
  61405. $encodingList = array_map('trim', explode(',', $encodingList));
  61406. }
  61407. $encodingList = array_map('strtoupper', $encodingList);
  61408. foreach ($encodingList as $enc) {
  61409. switch ($enc) {
  61410. default:
  61411. if (strncmp($enc, 'ISO-8859-', 9)) {
  61412. return false;
  61413. }
  61414. case 'ASCII':
  61415. case 'UTF8':
  61416. case 'UTF-8':
  61417. }
  61418. }
  61419. self::$encodingList = $encodingList;
  61420. return true;
  61421. }
  61422. public static function mb_strlen($s, $encoding = null)
  61423. {
  61424. $encoding = self::getEncoding($encoding);
  61425. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  61426. return \strlen($s);
  61427. }
  61428. return @iconv_strlen($s, $encoding);
  61429. }
  61430. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  61431. {
  61432. $encoding = self::getEncoding($encoding);
  61433. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  61434. return strpos($haystack, $needle, $offset);
  61435. }
  61436. $needle = (string) $needle;
  61437. if ('' === $needle) {
  61438. trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
  61439. return false;
  61440. }
  61441. return iconv_strpos($haystack, $needle, $offset, $encoding);
  61442. }
  61443. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  61444. {
  61445. $encoding = self::getEncoding($encoding);
  61446. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  61447. return strrpos($haystack, $needle, $offset);
  61448. }
  61449. if ($offset != (int) $offset) {
  61450. $offset = 0;
  61451. } elseif ($offset = (int) $offset) {
  61452. if ($offset < 0) {
  61453. if (0 > $offset += self::mb_strlen($needle)) {
  61454. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  61455. }
  61456. $offset = 0;
  61457. } else {
  61458. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  61459. }
  61460. }
  61461. $pos = iconv_strrpos($haystack, $needle, $encoding);
  61462. return false !== $pos ? $offset + $pos : false;
  61463. }
  61464. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  61465. {
  61466. if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
  61467. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
  61468. return null;
  61469. }
  61470. if (1 > $split_length = (int) $split_length) {
  61471. trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
  61472. return false;
  61473. }
  61474. if (null === $encoding) {
  61475. $encoding = mb_internal_encoding();
  61476. }
  61477. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  61478. $rx = '/(';
  61479. while (65535 < $split_length) {
  61480. $rx .= '.{65535}';
  61481. $split_length -= 65535;
  61482. }
  61483. $rx .= '.{'.$split_length.'})/us';
  61484. return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  61485. }
  61486. $result = array();
  61487. $length = mb_strlen($string, $encoding);
  61488. for ($i = 0; $i < $length; $i += $split_length) {
  61489. $result[] = mb_substr($string, $i, $split_length, $encoding);
  61490. }
  61491. return $result;
  61492. }
  61493. public static function mb_strtolower($s, $encoding = null)
  61494. {
  61495. return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
  61496. }
  61497. public static function mb_strtoupper($s, $encoding = null)
  61498. {
  61499. return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
  61500. }
  61501. public static function mb_substitute_character($c = null)
  61502. {
  61503. if (0 === strcasecmp($c, 'none')) {
  61504. return true;
  61505. }
  61506. return null !== $c ? false : 'none';
  61507. }
  61508. public static function mb_substr($s, $start, $length = null, $encoding = null)
  61509. {
  61510. $encoding = self::getEncoding($encoding);
  61511. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  61512. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  61513. }
  61514. if ($start < 0) {
  61515. $start = iconv_strlen($s, $encoding) + $start;
  61516. if ($start < 0) {
  61517. $start = 0;
  61518. }
  61519. }
  61520. if (null === $length) {
  61521. $length = 2147483647;
  61522. } elseif ($length < 0) {
  61523. $length = iconv_strlen($s, $encoding) + $length - $start;
  61524. if ($length < 0) {
  61525. return '';
  61526. }
  61527. }
  61528. return (string) iconv_substr($s, $start, $length, $encoding);
  61529. }
  61530. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  61531. {
  61532. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  61533. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  61534. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  61535. }
  61536. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  61537. {
  61538. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  61539. return self::getSubpart($pos, $part, $haystack, $encoding);
  61540. }
  61541. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  61542. {
  61543. $encoding = self::getEncoding($encoding);
  61544. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  61545. $pos = strrpos($haystack, $needle);
  61546. } else {
  61547. $needle = self::mb_substr($needle, 0, 1, $encoding);
  61548. $pos = iconv_strrpos($haystack, $needle, $encoding);
  61549. }
  61550. return self::getSubpart($pos, $part, $haystack, $encoding);
  61551. }
  61552. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  61553. {
  61554. $needle = self::mb_substr($needle, 0, 1, $encoding);
  61555. $pos = self::mb_strripos($haystack, $needle, $encoding);
  61556. return self::getSubpart($pos, $part, $haystack, $encoding);
  61557. }
  61558. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  61559. {
  61560. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  61561. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  61562. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  61563. }
  61564. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  61565. {
  61566. $pos = strpos($haystack, $needle);
  61567. if (false === $pos) {
  61568. return false;
  61569. }
  61570. if ($part) {
  61571. return substr($haystack, 0, $pos);
  61572. }
  61573. return substr($haystack, $pos);
  61574. }
  61575. public static function mb_get_info($type = 'all')
  61576. {
  61577. $info = array(
  61578. 'internal_encoding' => self::$internalEncoding,
  61579. 'http_output' => 'pass',
  61580. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  61581. 'func_overload' => 0,
  61582. 'func_overload_list' => 'no overload',
  61583. 'mail_charset' => 'UTF-8',
  61584. 'mail_header_encoding' => 'BASE64',
  61585. 'mail_body_encoding' => 'BASE64',
  61586. 'illegal_chars' => 0,
  61587. 'encoding_translation' => 'Off',
  61588. 'language' => self::$language,
  61589. 'detect_order' => self::$encodingList,
  61590. 'substitute_character' => 'none',
  61591. 'strict_detection' => 'Off',
  61592. );
  61593. if ('all' === $type) {
  61594. return $info;
  61595. }
  61596. if (isset($info[$type])) {
  61597. return $info[$type];
  61598. }
  61599. return false;
  61600. }
  61601. public static function mb_http_input($type = '')
  61602. {
  61603. return false;
  61604. }
  61605. public static function mb_http_output($encoding = null)
  61606. {
  61607. return null !== $encoding ? 'pass' === $encoding : 'pass';
  61608. }
  61609. public static function mb_strwidth($s, $encoding = null)
  61610. {
  61611. $encoding = self::getEncoding($encoding);
  61612. if ('UTF-8' !== $encoding) {
  61613. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  61614. }
  61615. $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);
  61616. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  61617. }
  61618. public static function mb_substr_count($haystack, $needle, $encoding = null)
  61619. {
  61620. return substr_count($haystack, $needle);
  61621. }
  61622. public static function mb_output_handler($contents, $status)
  61623. {
  61624. return $contents;
  61625. }
  61626. public static function mb_chr($code, $encoding = null)
  61627. {
  61628. if (0x80 > $code %= 0x200000) {
  61629. $s = \chr($code);
  61630. } elseif (0x800 > $code) {
  61631. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  61632. } elseif (0x10000 > $code) {
  61633. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  61634. } else {
  61635. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  61636. }
  61637. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  61638. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  61639. }
  61640. return $s;
  61641. }
  61642. public static function mb_ord($s, $encoding = null)
  61643. {
  61644. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  61645. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  61646. }
  61647. if (1 === \strlen($s)) {
  61648. return \ord($s);
  61649. }
  61650. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  61651. if (0xF0 <= $code) {
  61652. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  61653. }
  61654. if (0xE0 <= $code) {
  61655. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  61656. }
  61657. if (0xC0 <= $code) {
  61658. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  61659. }
  61660. return $code;
  61661. }
  61662. private static function getSubpart($pos, $part, $haystack, $encoding)
  61663. {
  61664. if (false === $pos) {
  61665. return false;
  61666. }
  61667. if ($part) {
  61668. return self::mb_substr($haystack, 0, $pos, $encoding);
  61669. }
  61670. return self::mb_substr($haystack, $pos, null, $encoding);
  61671. }
  61672. private static function html_encoding_callback(array $m)
  61673. {
  61674. $i = 1;
  61675. $entities = '';
  61676. $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
  61677. while (isset($m[$i])) {
  61678. if (0x80 > $m[$i]) {
  61679. $entities .= \chr($m[$i++]);
  61680. continue;
  61681. }
  61682. if (0xF0 <= $m[$i]) {
  61683. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  61684. } elseif (0xE0 <= $m[$i]) {
  61685. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  61686. } else {
  61687. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  61688. }
  61689. $entities .= '&#'.$c.';';
  61690. }
  61691. return $entities;
  61692. }
  61693. private static function title_case(array $s)
  61694. {
  61695. return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
  61696. }
  61697. private static function getData($file)
  61698. {
  61699. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  61700. return require $file;
  61701. }
  61702. return false;
  61703. }
  61704. private static function getEncoding($encoding)
  61705. {
  61706. if (null === $encoding) {
  61707. return self::$internalEncoding;
  61708. }
  61709. if ('UTF-8' === $encoding) {
  61710. return 'UTF-8';
  61711. }
  61712. $encoding = strtoupper($encoding);
  61713. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  61714. return 'CP850';
  61715. }
  61716. if ('UTF8' === $encoding) {
  61717. return 'UTF-8';
  61718. }
  61719. return $encoding;
  61720. }
  61721. }
  61722. <?php
  61723. use Symfony\Polyfill\Mbstring as p;
  61724. if (!function_exists('mb_convert_variables')) {
  61725. function mb_convert_variables($to_encoding, $from_encoding, &$var, &...$vars)
  61726. {
  61727. $vars = [&$var, ...$vars];
  61728. $ok = true;
  61729. array_walk_recursive($vars, function (&$v) use (&$ok, $to_encoding, $from_encoding) {
  61730. if (false === $v = p\Mbstring::mb_convert_encoding($v, $to_encoding, $from_encoding)) {
  61731. $ok = false;
  61732. }
  61733. });
  61734. return $ok ? $from_encoding : false;
  61735. }
  61736. }
  61737. <?php
  61738. return array (
  61739. 'A' => 'a',
  61740. 'B' => 'b',
  61741. 'C' => 'c',
  61742. 'D' => 'd',
  61743. 'E' => 'e',
  61744. 'F' => 'f',
  61745. 'G' => 'g',
  61746. 'H' => 'h',
  61747. 'I' => 'i',
  61748. 'J' => 'j',
  61749. 'K' => 'k',
  61750. 'L' => 'l',
  61751. 'M' => 'm',
  61752. 'N' => 'n',
  61753. 'O' => 'o',
  61754. 'P' => 'p',
  61755. 'Q' => 'q',
  61756. 'R' => 'r',
  61757. 'S' => 's',
  61758. 'T' => 't',
  61759. 'U' => 'u',
  61760. 'V' => 'v',
  61761. 'W' => 'w',
  61762. 'X' => 'x',
  61763. 'Y' => 'y',
  61764. 'Z' => 'z',
  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. 'Ä°' => 'i',
  61820. 'IJ' => 'ij',
  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. 'DŽ' => 'dž',
  61895. 'Dž' => 'dž',
  61896. 'LJ' => 'lj',
  61897. 'Lj' => 'lj',
  61898. 'NJ' => 'nj',
  61899. 'Nj' => 'nj',
  61900. '�' => 'ǎ',
  61901. '�' => '�',
  61902. 'Ç‘' => 'Ç’',
  61903. 'Ç“' => 'Ç”',
  61904. 'Ç•' => 'Ç–',
  61905. 'Ǘ' => 'ǘ',
  61906. 'Ç™' => 'Çš',
  61907. 'Ǜ' => 'ǜ',
  61908. 'Çž' => 'ÇŸ',
  61909. 'Ç ' => 'Ç¡',
  61910. 'Ç¢' => 'Ç£',
  61911. 'Ǥ' => 'ǥ',
  61912. 'Ǧ' => 'ǧ',
  61913. 'Ǩ' => 'ǩ',
  61914. 'Ǫ' => 'ǫ',
  61915. 'Ǭ' => 'ǭ',
  61916. 'Ǯ' => 'ǯ',
  61917. 'DZ' => 'dz',
  61918. 'Dz' => 'dz',
  61919. 'Ǵ' => 'ǵ',
  61920. 'Ƕ' => 'ƕ',
  61921. 'Ç·' => 'Æ¿',
  61922. 'Ǹ' => 'ǹ',
  61923. 'Ǻ' => 'ǻ',
  61924. 'Ǽ' => 'ǽ',
  61925. 'Ǿ' => 'ǿ',
  61926. 'Ȁ' => '�',
  61927. 'Ȃ' => 'ȃ',
  61928. 'È„' => 'È…',
  61929. 'Ȇ' => 'ȇ',
  61930. 'Ȉ' => 'ȉ',
  61931. 'ÈŠ' => 'È‹',
  61932. 'Ȍ' => '�',
  61933. 'Ȏ' => '�',
  61934. '�' => 'ȑ',
  61935. 'È’' => 'È“',
  61936. 'È”' => 'È•',
  61937. 'È–' => 'È—',
  61938. 'Ș' => 'ș',
  61939. 'Èš' => 'È›',
  61940. 'Ȝ' => '�',
  61941. 'Èž' => 'ÈŸ',
  61942. 'È ' => 'Æž',
  61943. 'È¢' => 'È£',
  61944. 'Ȥ' => 'ȥ',
  61945. 'Ȧ' => 'ȧ',
  61946. 'Ȩ' => 'ȩ',
  61947. 'Ȫ' => 'ȫ',
  61948. 'Ȭ' => 'ȭ',
  61949. 'Ȯ' => 'ȯ',
  61950. 'Ȱ' => 'ȱ',
  61951. 'Ȳ' => 'ȳ',
  61952. 'Ⱥ' => 'ⱥ',
  61953. 'Ȼ' => 'ȼ',
  61954. 'Ƚ' => 'ƚ',
  61955. 'Ⱦ' => 'ⱦ',
  61956. '�' => 'ɂ',
  61957. 'Ƀ' => 'ƀ',
  61958. 'Ʉ' => 'ʉ',
  61959. 'Ʌ' => 'ʌ',
  61960. 'Ɇ' => 'ɇ',
  61961. 'Ɉ' => 'ɉ',
  61962. 'ÉŠ' => 'É‹',
  61963. 'Ɍ' => '�',
  61964. 'Ɏ' => '�',
  61965. 'Ͱ' => 'ͱ',
  61966. 'Ͳ' => 'ͳ',
  61967. 'Ͷ' => 'ͷ',
  61968. 'Ϳ' => 'ϳ',
  61969. 'Ά' => 'ά',
  61970. 'Έ' => 'έ',
  61971. 'Ή' => 'ή',
  61972. 'Ί' => 'ί',
  61973. 'Ό' => 'ό',
  61974. 'Ύ' => '�',
  61975. '�' => 'ώ',
  61976. 'Α' => 'α',
  61977. 'Β' => 'β',
  61978. 'Γ' => 'γ',
  61979. 'Δ' => 'δ',
  61980. 'Ε' => 'ε',
  61981. 'Ζ' => 'ζ',
  61982. 'Η' => 'η',
  61983. 'Θ' => 'θ',
  61984. 'Ι' => 'ι',
  61985. 'Κ' => 'κ',
  61986. 'Λ' => 'λ',
  61987. 'Μ' => 'μ',
  61988. '�' => 'ν',
  61989. 'Ξ' => 'ξ',
  61990. 'Ο' => 'ο',
  61991. 'Π' => 'π',
  61992. 'Ρ' => '�',
  61993. 'Σ' => 'σ',
  61994. 'Τ' => 'τ',
  61995. 'Î¥' => 'Ï…',
  61996. 'Φ' => 'φ',
  61997. 'Χ' => 'χ',
  61998. 'Ψ' => 'ψ',
  61999. 'Ω' => 'ω',
  62000. 'Ϊ' => 'ϊ',
  62001. 'Ϋ' => 'ϋ',
  62002. '�' => 'ϗ',
  62003. 'Ϙ' => 'ϙ',
  62004. 'Ïš' => 'Ï›',
  62005. 'Ϝ' => '�',
  62006. 'Ïž' => 'ÏŸ',
  62007. 'Ï ' => 'Ï¡',
  62008. 'Ï¢' => 'Ï£',
  62009. 'Ϥ' => 'ϥ',
  62010. 'Ϧ' => 'ϧ',
  62011. 'Ϩ' => 'ϩ',
  62012. 'Ϫ' => 'ϫ',
  62013. 'Ϭ' => 'ϭ',
  62014. 'Ϯ' => 'ϯ',
  62015. 'ϴ' => 'θ',
  62016. 'Ϸ' => 'ϸ',
  62017. 'Ϲ' => 'ϲ',
  62018. 'Ϻ' => 'ϻ',
  62019. 'Ͻ' => 'ͻ',
  62020. 'Ͼ' => 'ͼ',
  62021. 'Ͽ' => 'ͽ',
  62022. 'Ѐ' => '�',
  62023. '�' => 'ё',
  62024. 'Ђ' => 'ђ',
  62025. 'Ѓ' => 'ѓ',
  62026. 'Є' => 'є',
  62027. 'Ð…' => 'Ñ•',
  62028. 'І' => 'і',
  62029. 'Ї' => 'ї',
  62030. 'Ј' => 'ј',
  62031. 'Љ' => 'љ',
  62032. 'Њ' => 'њ',
  62033. 'Ћ' => 'ћ',
  62034. 'Ќ' => 'ќ',
  62035. '�' => '�',
  62036. 'ÐŽ' => 'Ñž',
  62037. '�' => 'џ',
  62038. '�' => 'а',
  62039. 'Б' => 'б',
  62040. 'В' => 'в',
  62041. 'Г' => 'г',
  62042. 'Д' => 'д',
  62043. 'Е' => 'е',
  62044. 'Ж' => 'ж',
  62045. 'З' => 'з',
  62046. 'И' => 'и',
  62047. 'Й' => 'й',
  62048. 'К' => 'к',
  62049. 'Л' => 'л',
  62050. 'М' => 'м',
  62051. '�' => 'н',
  62052. 'О' => 'о',
  62053. 'П' => 'п',
  62054. 'Р' => 'р',
  62055. 'С' => '�',
  62056. 'Т' => 'т',
  62057. 'У' => 'у',
  62058. 'Ф' => 'ф',
  62059. 'Ð¥' => 'Ñ…',
  62060. 'Ц' => 'ц',
  62061. 'Ч' => 'ч',
  62062. 'Ш' => 'ш',
  62063. 'Щ' => 'щ',
  62064. 'Ъ' => 'ъ',
  62065. 'Ы' => 'ы',
  62066. 'Ь' => 'ь',
  62067. 'Э' => '�',
  62068. 'Ю' => 'ю',
  62069. 'Я' => '�',
  62070. 'Ñ ' => 'Ñ¡',
  62071. 'Ñ¢' => 'Ñ£',
  62072. 'Ѥ' => 'ѥ',
  62073. 'Ѧ' => 'ѧ',
  62074. 'Ѩ' => 'ѩ',
  62075. 'Ѫ' => 'ѫ',
  62076. 'Ѭ' => 'ѭ',
  62077. 'Ѯ' => 'ѯ',
  62078. 'Ѱ' => 'ѱ',
  62079. 'Ѳ' => 'ѳ',
  62080. 'Ѵ' => 'ѵ',
  62081. 'Ѷ' => 'ѷ',
  62082. 'Ѹ' => 'ѹ',
  62083. 'Ѻ' => 'ѻ',
  62084. 'Ѽ' => 'ѽ',
  62085. 'Ѿ' => 'ѿ',
  62086. 'Ò€' => 'Ò�',
  62087. 'ÒŠ' => 'Ò‹',
  62088. 'Ҍ' => '�',
  62089. 'ÒŽ' => 'Ò�',
  62090. 'Ò�' => 'Ò‘',
  62091. 'Ò’' => 'Ò“',
  62092. 'Ò”' => 'Ò•',
  62093. 'Ò–' => 'Ò—',
  62094. 'Ò˜' => 'Ò™',
  62095. 'Òš' => 'Ò›',
  62096. 'Ҝ' => '�',
  62097. 'Òž' => 'ÒŸ',
  62098. 'Ò ' => 'Ò¡',
  62099. 'Ò¢' => 'Ò£',
  62100. 'Ò¤' => 'Ò¥',
  62101. 'Ò¦' => 'Ò§',
  62102. 'Ò¨' => 'Ò©',
  62103. 'Òª' => 'Ò«',
  62104. 'Ò¬' => 'Ò­',
  62105. 'Ò®' => 'Ò¯',
  62106. 'Ò°' => 'Ò±',
  62107. 'Ò²' => 'Ò³',
  62108. 'Ò´' => 'Òµ',
  62109. 'Ò¶' => 'Ò·',
  62110. 'Ò¸' => 'Ò¹',
  62111. 'Òº' => 'Ò»',
  62112. 'Ò¼' => 'Ò½',
  62113. 'Ò¾' => 'Ò¿',
  62114. 'Ó€' => 'Ó�',
  62115. 'Ó�' => 'Ó‚',
  62116. 'Óƒ' => 'Ó„',
  62117. 'Ó…' => 'Ó†',
  62118. 'Ó‡' => 'Óˆ',
  62119. 'Ó‰' => 'ÓŠ',
  62120. 'Ӌ' => 'ӌ',
  62121. 'Ó�' => 'ÓŽ',
  62122. 'Ó�' => 'Ó‘',
  62123. 'Ó’' => 'Ó“',
  62124. 'Ó”' => 'Ó•',
  62125. 'Ó–' => 'Ó—',
  62126. 'Ó˜' => 'Ó™',
  62127. 'Óš' => 'Ó›',
  62128. 'Ӝ' => '�',
  62129. 'Óž' => 'ÓŸ',
  62130. 'Ó ' => 'Ó¡',
  62131. 'Ó¢' => 'Ó£',
  62132. 'Ó¤' => 'Ó¥',
  62133. 'Ó¦' => 'Ó§',
  62134. 'Ó¨' => 'Ó©',
  62135. 'Óª' => 'Ó«',
  62136. 'Ó¬' => 'Ó­',
  62137. 'Ó®' => 'Ó¯',
  62138. 'Ó°' => 'Ó±',
  62139. 'Ó²' => 'Ó³',
  62140. 'Ó´' => 'Óµ',
  62141. 'Ó¶' => 'Ó·',
  62142. 'Ó¸' => 'Ó¹',
  62143. 'Óº' => 'Ó»',
  62144. 'Ó¼' => 'Ó½',
  62145. 'Ó¾' => 'Ó¿',
  62146. 'Ô€' => 'Ô�',
  62147. 'Ô‚' => 'Ôƒ',
  62148. 'Ô„' => 'Ô…',
  62149. 'Ô†' => 'Ô‡',
  62150. 'Ôˆ' => 'Ô‰',
  62151. 'ÔŠ' => 'Ô‹',
  62152. 'Ԍ' => '�',
  62153. 'ÔŽ' => 'Ô�',
  62154. 'Ô�' => 'Ô‘',
  62155. 'Ô’' => 'Ô“',
  62156. 'Ô”' => 'Ô•',
  62157. 'Ô–' => 'Ô—',
  62158. 'Ô˜' => 'Ô™',
  62159. 'Ôš' => 'Ô›',
  62160. 'Ԝ' => '�',
  62161. 'Ôž' => 'ÔŸ',
  62162. 'Ô ' => 'Ô¡',
  62163. 'Ô¢' => 'Ô£',
  62164. 'Ô¤' => 'Ô¥',
  62165. 'Ô¦' => 'Ô§',
  62166. 'Ô¨' => 'Ô©',
  62167. 'Ôª' => 'Ô«',
  62168. 'Ô¬' => 'Ô­',
  62169. 'Ô®' => 'Ô¯',
  62170. 'Ô±' => 'Õ¡',
  62171. 'Ô²' => 'Õ¢',
  62172. 'Ô³' => 'Õ£',
  62173. 'Ô´' => 'Õ¤',
  62174. 'Ôµ' => 'Õ¥',
  62175. 'Ô¶' => 'Õ¦',
  62176. 'Ô·' => 'Õ§',
  62177. 'Ô¸' => 'Õ¨',
  62178. 'Ô¹' => 'Õ©',
  62179. 'Ôº' => 'Õª',
  62180. 'Ô»' => 'Õ«',
  62181. 'Ô¼' => 'Õ¬',
  62182. 'Ô½' => 'Õ­',
  62183. 'Ô¾' => 'Õ®',
  62184. 'Ô¿' => 'Õ¯',
  62185. 'Õ€' => 'Õ°',
  62186. 'Õ�' => 'Õ±',
  62187. 'Õ‚' => 'Õ²',
  62188. 'Õƒ' => 'Õ³',
  62189. 'Õ„' => 'Õ´',
  62190. 'Õ…' => 'Õµ',
  62191. 'Õ†' => 'Õ¶',
  62192. 'Õ‡' => 'Õ·',
  62193. 'Õˆ' => 'Õ¸',
  62194. 'Õ‰' => 'Õ¹',
  62195. 'ÕŠ' => 'Õº',
  62196. 'Õ‹' => 'Õ»',
  62197. 'Ռ' => 'ռ',
  62198. 'Õ�' => 'Õ½',
  62199. 'ÕŽ' => 'Õ¾',
  62200. 'Õ�' => 'Õ¿',
  62201. 'Õ�' => 'Ö€',
  62202. 'Õ‘' => 'Ö�',
  62203. 'Õ’' => 'Ö‚',
  62204. 'Õ“' => 'Öƒ',
  62205. 'Õ”' => 'Ö„',
  62206. 'Õ•' => 'Ö…',
  62207. 'Õ–' => 'Ö†',
  62208. 'á‚ ' => 'â´€',
  62209. 'á‚¡' => 'â´�',
  62210. 'á‚¢' => 'â´‚',
  62211. 'á‚£' => 'â´ƒ',
  62212. 'Ⴄ' => 'ⴄ',
  62213. 'á‚¥' => 'â´…',
  62214. 'Ⴆ' => 'ⴆ',
  62215. 'Ⴇ' => 'ⴇ',
  62216. 'Ⴈ' => 'ⴈ',
  62217. 'á‚©' => 'â´‰',
  62218. 'Ⴊ' => 'ⴊ',
  62219. 'á‚«' => 'â´‹',
  62220. 'Ⴌ' => 'ⴌ',
  62221. 'á‚­' => 'â´�',
  62222. 'á‚®' => 'â´Ž',
  62223. 'Ⴏ' => '�',
  62224. 'á‚°' => 'â´�',
  62225. 'Ⴑ' => 'ⴑ',
  62226. 'Ⴒ' => 'ⴒ',
  62227. 'Ⴓ' => 'ⴓ',
  62228. 'á‚´' => 'â´”',
  62229. 'Ⴕ' => 'ⴕ',
  62230. 'Ⴖ' => 'ⴖ',
  62231. 'á‚·' => 'â´—',
  62232. 'Ⴘ' => 'ⴘ',
  62233. 'Ⴙ' => 'ⴙ',
  62234. 'Ⴚ' => 'ⴚ',
  62235. 'á‚»' => 'â´›',
  62236. 'Ⴜ' => 'ⴜ',
  62237. 'Ⴝ' => '�',
  62238. 'Ⴞ' => 'ⴞ',
  62239. 'á‚¿' => 'â´Ÿ',
  62240. 'Ⴠ' => 'ⴠ',
  62241. '�' => 'ⴡ',
  62242. 'Ⴢ' => 'ⴢ',
  62243. 'Ⴣ' => 'ⴣ',
  62244. 'Ⴤ' => 'ⴤ',
  62245. 'Ⴥ' => 'ⴥ',
  62246. 'Ⴧ' => 'ⴧ',
  62247. '�' => 'ⴭ',
  62248. 'Ꭰ' => 'ꭰ',
  62249. 'Ꭱ' => 'ꭱ',
  62250. 'Ꭲ' => 'ꭲ',
  62251. 'Ꭳ' => 'ꭳ',
  62252. 'Ꭴ' => 'ꭴ',
  62253. 'Ꭵ' => 'ꭵ',
  62254. 'Ꭶ' => 'ꭶ',
  62255. 'Ꭷ' => 'ꭷ',
  62256. 'Ꭸ' => 'ꭸ',
  62257. 'Ꭹ' => 'ꭹ',
  62258. 'Ꭺ' => 'ꭺ',
  62259. 'Ꭻ' => 'ꭻ',
  62260. 'Ꭼ' => 'ꭼ',
  62261. 'Ꭽ' => 'ꭽ',
  62262. 'Ꭾ' => 'ꭾ',
  62263. 'Ꭿ' => 'ꭿ',
  62264. 'Ꮀ' => 'ꮀ',
  62265. 'Ꮁ' => '�',
  62266. 'Ꮂ' => 'ꮂ',
  62267. 'Ꮃ' => 'ꮃ',
  62268. 'Ꮄ' => 'ꮄ',
  62269. 'Ꮅ' => 'ꮅ',
  62270. 'Ꮆ' => 'ꮆ',
  62271. 'Ꮇ' => 'ꮇ',
  62272. 'Ꮈ' => 'ꮈ',
  62273. 'Ꮉ' => 'ꮉ',
  62274. 'Ꮊ' => 'ꮊ',
  62275. 'Ꮋ' => 'ꮋ',
  62276. 'Ꮌ' => 'ꮌ',
  62277. 'Ꮍ' => '�',
  62278. 'Ꮎ' => 'ꮎ',
  62279. 'Ꮏ' => '�',
  62280. '�' => '�',
  62281. '�' => 'ꮑ',
  62282. '�' => 'ꮒ',
  62283. '�' => 'ꮓ',
  62284. '�' => 'ꮔ',
  62285. '�' => 'ꮕ',
  62286. '�' => 'ꮖ',
  62287. '�' => 'ꮗ',
  62288. '�' => 'ꮘ',
  62289. '�' => 'ꮙ',
  62290. '�' => 'ꮚ',
  62291. '�' => 'ꮛ',
  62292. '�' => 'ꮜ',
  62293. '�' => '�',
  62294. '�' => 'ꮞ',
  62295. '�' => 'ꮟ',
  62296. '�' => 'ꮠ',
  62297. '�' => 'ꮡ',
  62298. '�' => 'ꮢ',
  62299. '�' => 'ꮣ',
  62300. '�' => 'ꮤ',
  62301. '�' => 'ꮥ',
  62302. '�' => 'ꮦ',
  62303. '�' => 'ꮧ',
  62304. '�' => 'ꮨ',
  62305. '�' => 'ꮩ',
  62306. '�' => 'ꮪ',
  62307. '�' => 'ꮫ',
  62308. '�' => 'ꮬ',
  62309. '�' => 'ꮭ',
  62310. '�' => 'ꮮ',
  62311. '�' => 'ꮯ',
  62312. '�' => 'ꮰ',
  62313. '�' => 'ꮱ',
  62314. '�' => 'ꮲ',
  62315. '�' => 'ꮳ',
  62316. '�' => 'ꮴ',
  62317. '�' => 'ꮵ',
  62318. '�' => 'ꮶ',
  62319. '�' => 'ꮷ',
  62320. '�' => 'ꮸ',
  62321. '�' => 'ꮹ',
  62322. '�' => 'ꮺ',
  62323. '�' => 'ꮻ',
  62324. '�' => 'ꮼ',
  62325. '�' => 'ꮽ',
  62326. '�' => 'ꮾ',
  62327. '�' => 'ꮿ',
  62328. '�' => '�',
  62329. '�' => '�',
  62330. '�' => '�',
  62331. '�' => '�',
  62332. '�' => '�',
  62333. '�' => '�',
  62334. '�' => '�',
  62335. 'Ბ' => 'ბ',
  62336. 'Გ' => 'გ',
  62337. 'Დ' => 'დ',
  62338. 'Ე' => 'ე',
  62339. 'Ვ' => 'ვ',
  62340. 'Ზ' => 'ზ',
  62341. 'Თ' => 'თ',
  62342. 'Ი' => 'ი',
  62343. 'Კ' => 'კ',
  62344. 'Ლ' => 'ლ',
  62345. 'Მ' => 'მ',
  62346. 'Ნ' => 'ნ',
  62347. '�' => '�',
  62348. 'Პ' => 'პ',
  62349. 'Ჟ' => 'ჟ',
  62350. 'Რ' => 'რ',
  62351. 'Ს' => 'ს',
  62352. 'Ტ' => 'ტ',
  62353. 'Უ' => 'უ',
  62354. 'Ფ' => 'ფ',
  62355. 'Ქ' => 'ქ',
  62356. 'Ღ' => 'ღ',
  62357. 'Ყ' => 'ყ',
  62358. 'Შ' => 'შ',
  62359. 'Ჩ' => 'ჩ',
  62360. 'Ც' => 'ც',
  62361. 'Ძ' => 'ძ',
  62362. 'Წ' => 'წ',
  62363. 'Ჭ' => 'ჭ',
  62364. 'Ხ' => 'ხ',
  62365. 'Ჯ' => 'ჯ',
  62366. 'Ჰ' => 'ჰ',
  62367. 'Ჱ' => 'ჱ',
  62368. 'Ჲ' => 'ჲ',
  62369. 'Ჳ' => 'ჳ',
  62370. 'Ჴ' => 'ჴ',
  62371. 'Ჵ' => 'ჵ',
  62372. 'Ჶ' => 'ჶ',
  62373. 'Ჷ' => 'ჷ',
  62374. 'Ჸ' => 'ჸ',
  62375. 'Ჹ' => 'ჹ',
  62376. 'Ჺ' => 'ჺ',
  62377. 'Ჽ' => 'ჽ',
  62378. 'Ჾ' => 'ჾ',
  62379. 'Ჿ' => 'ჿ',
  62380. 'Ḁ' => '�',
  62381. 'Ḃ' => 'ḃ',
  62382. 'Ḅ' => 'ḅ',
  62383. 'Ḇ' => 'ḇ',
  62384. 'Ḉ' => 'ḉ',
  62385. 'Ḋ' => 'ḋ',
  62386. 'Ḍ' => '�',
  62387. 'Ḏ' => '�',
  62388. '�' => 'ḑ',
  62389. 'Ḓ' => 'ḓ',
  62390. 'Ḕ' => 'ḕ',
  62391. 'Ḗ' => 'ḗ',
  62392. 'Ḙ' => 'ḙ',
  62393. 'Ḛ' => 'ḛ',
  62394. 'Ḝ' => '�',
  62395. 'Ḟ' => 'ḟ',
  62396. 'Ḡ' => 'ḡ',
  62397. 'Ḣ' => 'ḣ',
  62398. 'Ḥ' => 'ḥ',
  62399. 'Ḧ' => 'ḧ',
  62400. 'Ḩ' => 'ḩ',
  62401. 'Ḫ' => 'ḫ',
  62402. 'Ḭ' => 'ḭ',
  62403. 'Ḯ' => 'ḯ',
  62404. 'Ḱ' => 'ḱ',
  62405. 'Ḳ' => 'ḳ',
  62406. 'Ḵ' => 'ḵ',
  62407. 'Ḷ' => 'ḷ',
  62408. 'Ḹ' => 'ḹ',
  62409. 'Ḻ' => 'ḻ',
  62410. 'Ḽ' => 'ḽ',
  62411. 'Ḿ' => 'ḿ',
  62412. 'Ṁ' => '�',
  62413. 'Ṃ' => 'ṃ',
  62414. 'Ṅ' => 'ṅ',
  62415. 'Ṇ' => 'ṇ',
  62416. 'Ṉ' => 'ṉ',
  62417. 'Ṋ' => 'ṋ',
  62418. 'Ṍ' => '�',
  62419. 'Ṏ' => '�',
  62420. '�' => 'ṑ',
  62421. 'Ṓ' => 'ṓ',
  62422. 'Ṕ' => 'ṕ',
  62423. 'á¹–' => 'á¹—',
  62424. 'Ṙ' => 'ṙ',
  62425. 'Ṛ' => 'ṛ',
  62426. 'Ṝ' => '�',
  62427. 'Ṟ' => 'ṟ',
  62428. 'Ṡ' => 'ṡ',
  62429. 'á¹¢' => 'á¹£',
  62430. 'Ṥ' => 'ṥ',
  62431. 'Ṧ' => 'ṧ',
  62432. 'Ṩ' => 'ṩ',
  62433. 'Ṫ' => 'ṫ',
  62434. 'Ṭ' => 'ṭ',
  62435. 'Ṯ' => 'ṯ',
  62436. 'á¹°' => 'á¹±',
  62437. 'á¹²' => 'á¹³',
  62438. 'á¹´' => 'á¹µ',
  62439. 'Ṷ' => 'ṷ',
  62440. 'Ṹ' => 'ṹ',
  62441. 'Ṻ' => 'ṻ',
  62442. 'á¹¼' => 'á¹½',
  62443. 'Ṿ' => 'ṿ',
  62444. 'Ẁ' => '�',
  62445. 'Ẃ' => 'ẃ',
  62446. 'Ẅ' => 'ẅ',
  62447. 'Ẇ' => 'ẇ',
  62448. 'Ẉ' => 'ẉ',
  62449. 'Ẋ' => 'ẋ',
  62450. 'Ẍ' => '�',
  62451. 'Ẏ' => '�',
  62452. '�' => 'ẑ',
  62453. 'Ẓ' => 'ẓ',
  62454. 'Ẕ' => 'ẕ',
  62455. 'ẞ' => 'ß',
  62456. 'Ạ' => 'ạ',
  62457. 'Ả' => 'ả',
  62458. 'Ấ' => 'ấ',
  62459. 'Ầ' => 'ầ',
  62460. 'Ẩ' => 'ẩ',
  62461. 'Ẫ' => 'ẫ',
  62462. 'Ậ' => 'ậ',
  62463. 'Ắ' => 'ắ',
  62464. 'Ằ' => 'ằ',
  62465. 'Ẳ' => 'ẳ',
  62466. 'Ẵ' => 'ẵ',
  62467. 'Ặ' => 'ặ',
  62468. 'Ẹ' => 'ẹ',
  62469. 'Ẻ' => 'ẻ',
  62470. 'Ẽ' => 'ẽ',
  62471. 'Ế' => 'ế',
  62472. 'Ề' => '�',
  62473. 'Ể' => 'ể',
  62474. 'Ễ' => 'ễ',
  62475. 'Ệ' => 'ệ',
  62476. 'Ỉ' => 'ỉ',
  62477. 'Ị' => 'ị',
  62478. 'Ọ' => '�',
  62479. 'Ỏ' => '�',
  62480. '�' => 'ố',
  62481. 'Ồ' => 'ồ',
  62482. 'Ổ' => 'ổ',
  62483. 'á»–' => 'á»—',
  62484. 'Ộ' => 'ộ',
  62485. 'Ớ' => 'ớ',
  62486. 'Ờ' => '�',
  62487. 'Ở' => 'ở',
  62488. 'Ỡ' => 'ỡ',
  62489. 'Ợ' => 'ợ',
  62490. 'Ụ' => 'ụ',
  62491. 'Ủ' => 'ủ',
  62492. 'Ứ' => 'ứ',
  62493. 'Ừ' => 'ừ',
  62494. 'Ử' => 'ử',
  62495. 'Ữ' => 'ữ',
  62496. 'á»°' => 'á»±',
  62497. 'Ỳ' => 'ỳ',
  62498. 'Ỵ' => 'ỵ',
  62499. 'Ỷ' => 'ỷ',
  62500. 'Ỹ' => 'ỹ',
  62501. 'Ỻ' => 'ỻ',
  62502. 'Ỽ' => 'ỽ',
  62503. 'Ỿ' => 'ỿ',
  62504. 'Ἀ' => 'ἀ',
  62505. 'Ἁ' => '�',
  62506. 'Ἂ' => 'ἂ',
  62507. 'Ἃ' => 'ἃ',
  62508. 'Ἄ' => 'ἄ',
  62509. '�' => 'ἅ',
  62510. 'Ἆ' => 'ἆ',
  62511. '�' => 'ἇ',
  62512. 'Ἐ' => '�',
  62513. 'Ἑ' => 'ἑ',
  62514. 'Ἒ' => 'ἒ',
  62515. 'Ἓ' => 'ἓ',
  62516. 'Ἔ' => 'ἔ',
  62517. '�' => 'ἕ',
  62518. 'Ἠ' => 'ἠ',
  62519. 'Ἡ' => 'ἡ',
  62520. 'Ἢ' => 'ἢ',
  62521. 'Ἣ' => 'ἣ',
  62522. 'Ἤ' => 'ἤ',
  62523. 'á¼­' => 'á¼¥',
  62524. 'Ἦ' => 'ἦ',
  62525. 'Ἧ' => 'ἧ',
  62526. 'Ἰ' => 'ἰ',
  62527. 'á¼¹' => 'á¼±',
  62528. 'Ἲ' => 'ἲ',
  62529. 'á¼»' => 'á¼³',
  62530. 'á¼¼' => 'á¼´',
  62531. 'á¼½' => 'á¼µ',
  62532. 'Ἶ' => 'ἶ',
  62533. 'Ἷ' => 'ἷ',
  62534. 'Ὀ' => 'ὀ',
  62535. 'Ὁ' => '�',
  62536. 'Ὂ' => 'ὂ',
  62537. 'Ὃ' => 'ὃ',
  62538. 'Ὄ' => 'ὄ',
  62539. '�' => 'ὅ',
  62540. 'Ὑ' => 'ὑ',
  62541. 'Ὓ' => 'ὓ',
  62542. '�' => 'ὕ',
  62543. 'Ὗ' => 'ὗ',
  62544. 'Ὠ' => 'ὠ',
  62545. 'Ὡ' => 'ὡ',
  62546. 'Ὢ' => 'ὢ',
  62547. 'Ὣ' => 'ὣ',
  62548. 'Ὤ' => 'ὤ',
  62549. 'á½­' => 'á½¥',
  62550. 'Ὦ' => 'ὦ',
  62551. 'Ὧ' => 'ὧ',
  62552. 'ᾈ' => 'ᾀ',
  62553. 'ᾉ' => '�',
  62554. 'ᾊ' => 'ᾂ',
  62555. 'ᾋ' => 'ᾃ',
  62556. 'ᾌ' => 'ᾄ',
  62557. '�' => 'ᾅ',
  62558. 'ᾎ' => 'ᾆ',
  62559. '�' => 'ᾇ',
  62560. 'ᾘ' => '�',
  62561. 'ᾙ' => 'ᾑ',
  62562. 'ᾚ' => 'ᾒ',
  62563. 'ᾛ' => 'ᾓ',
  62564. 'ᾜ' => 'ᾔ',
  62565. '�' => 'ᾕ',
  62566. 'ᾞ' => 'ᾖ',
  62567. 'ᾟ' => 'ᾗ',
  62568. 'ᾨ' => 'ᾠ',
  62569. 'ᾩ' => 'ᾡ',
  62570. 'ᾪ' => 'ᾢ',
  62571. 'ᾫ' => 'ᾣ',
  62572. 'ᾬ' => 'ᾤ',
  62573. 'á¾­' => 'á¾¥',
  62574. 'ᾮ' => 'ᾦ',
  62575. 'ᾯ' => 'ᾧ',
  62576. 'Ᾰ' => 'ᾰ',
  62577. 'á¾¹' => 'á¾±',
  62578. 'Ὰ' => 'ὰ',
  62579. 'á¾»' => 'á½±',
  62580. 'á¾¼' => 'á¾³',
  62581. 'Ὲ' => 'ὲ',
  62582. 'Έ' => 'έ',
  62583. 'á¿Š' => 'á½´',
  62584. 'á¿‹' => 'á½µ',
  62585. 'ῌ' => 'ῃ',
  62586. 'Ῐ' => '�',
  62587. 'á¿™' => 'á¿‘',
  62588. 'Ὶ' => 'ὶ',
  62589. 'á¿›' => 'á½·',
  62590. 'Ῠ' => 'ῠ',
  62591. 'á¿©' => 'á¿¡',
  62592. 'Ὺ' => 'ὺ',
  62593. 'á¿«' => 'á½»',
  62594. 'Ῥ' => 'ῥ',
  62595. 'Ὸ' => 'ὸ',
  62596. 'Ό' => 'ό',
  62597. 'Ὼ' => 'ὼ',
  62598. 'á¿»' => 'á½½',
  62599. 'ῼ' => 'ῳ',
  62600. 'Ω' => 'ω',
  62601. 'K' => 'k',
  62602. 'â„«' => 'Ã¥',
  62603. 'Ⅎ' => 'ⅎ',
  62604. 'â… ' => 'â…°',
  62605. 'â…¡' => 'â…±',
  62606. 'â…¢' => 'â…²',
  62607. 'â…£' => 'â…³',
  62608. 'â…¤' => 'â…´',
  62609. 'â…¥' => 'â…µ',
  62610. 'â…¦' => 'â…¶',
  62611. 'â…§' => 'â…·',
  62612. 'â…¨' => 'â…¸',
  62613. 'â…©' => 'â…¹',
  62614. 'â…ª' => 'â…º',
  62615. 'â…«' => 'â…»',
  62616. 'â…¬' => 'â…¼',
  62617. 'â…­' => 'â…½',
  62618. 'â…®' => 'â…¾',
  62619. 'â…¯' => 'â…¿',
  62620. 'Ↄ' => 'ↄ',
  62621. 'Ⓐ' => '�',
  62622. 'â’·' => 'â“‘',
  62623. 'â’¸' => 'â“’',
  62624. 'â’¹' => 'â““',
  62625. 'â’º' => 'â“”',
  62626. 'â’»' => 'â“•',
  62627. 'â’¼' => 'â“–',
  62628. 'â’½' => 'â“—',
  62629. 'Ⓘ' => 'ⓘ',
  62630. 'â’¿' => 'â“™',
  62631. 'â“€' => 'â“š',
  62632. '�' => 'ⓛ',
  62633. 'Ⓜ' => 'ⓜ',
  62634. 'Ⓝ' => '�',
  62635. 'â“„' => 'â“ž',
  62636. 'â“…' => 'â“Ÿ',
  62637. 'Ⓠ' => 'ⓠ',
  62638. 'Ⓡ' => 'ⓡ',
  62639. 'Ⓢ' => 'ⓢ',
  62640. 'Ⓣ' => 'ⓣ',
  62641. 'Ⓤ' => 'ⓤ',
  62642. 'â“‹' => 'â“¥',
  62643. 'Ⓦ' => 'ⓦ',
  62644. '�' => 'ⓧ',
  62645. 'Ⓨ' => 'ⓨ',
  62646. '�' => 'ⓩ',
  62647. 'â°€' => 'â°°',
  62648. 'â°�' => 'â°±',
  62649. 'â°‚' => 'â°²',
  62650. 'â°ƒ' => 'â°³',
  62651. 'â°„' => 'â°´',
  62652. 'â°…' => 'â°µ',
  62653. 'â°†' => 'â°¶',
  62654. 'â°‡' => 'â°·',
  62655. 'â°ˆ' => 'â°¸',
  62656. 'â°‰' => 'â°¹',
  62657. 'â°Š' => 'â°º',
  62658. 'â°‹' => 'â°»',
  62659. 'Ⰼ' => 'ⰼ',
  62660. 'â°�' => 'â°½',
  62661. 'â°Ž' => 'â°¾',
  62662. 'â°�' => 'â°¿',
  62663. 'â°�' => 'â±€',
  62664. 'Ⱁ' => '�',
  62665. 'Ⱂ' => 'ⱂ',
  62666. 'Ⱃ' => 'ⱃ',
  62667. 'Ⱄ' => 'ⱄ',
  62668. 'â°•' => 'â±…',
  62669. 'Ⱆ' => 'ⱆ',
  62670. 'Ⱇ' => 'ⱇ',
  62671. 'Ⱈ' => 'ⱈ',
  62672. 'Ⱉ' => 'ⱉ',
  62673. 'Ⱊ' => 'ⱊ',
  62674. 'Ⱋ' => 'ⱋ',
  62675. 'Ⱌ' => 'ⱌ',
  62676. '�' => '�',
  62677. 'Ⱎ' => 'ⱎ',
  62678. 'Ⱏ' => '�',
  62679. 'Ⱐ' => '�',
  62680. 'Ⱑ' => 'ⱑ',
  62681. 'â°¢' => 'â±’',
  62682. 'Ⱓ' => 'ⱓ',
  62683. 'â°¤' => 'â±”',
  62684. 'Ⱕ' => 'ⱕ',
  62685. 'â°¦' => 'â±–',
  62686. 'â°§' => 'â±—',
  62687. 'Ⱘ' => 'ⱘ',
  62688. 'â°©' => 'â±™',
  62689. 'Ⱚ' => 'ⱚ',
  62690. 'â°«' => 'â±›',
  62691. 'Ⱜ' => 'ⱜ',
  62692. 'Ⱝ' => '�',
  62693. 'Ⱞ' => 'ⱞ',
  62694. 'Ⱡ' => 'ⱡ',
  62695. 'â±¢' => 'É«',
  62696. 'â±£' => 'áµ½',
  62697. 'Ɽ' => 'ɽ',
  62698. 'Ⱨ' => 'ⱨ',
  62699. 'Ⱪ' => 'ⱪ',
  62700. 'Ⱬ' => 'ⱬ',
  62701. 'â±­' => 'É‘',
  62702. 'Ɱ' => 'ɱ',
  62703. 'Ɐ' => '�',
  62704. 'â±°' => 'É’',
  62705. 'â±²' => 'â±³',
  62706. 'Ⱶ' => 'ⱶ',
  62707. 'â±¾' => 'È¿',
  62708. 'Ɀ' => 'ɀ',
  62709. 'Ⲁ' => '�',
  62710. 'Ⲃ' => 'ⲃ',
  62711. 'Ⲅ' => 'ⲅ',
  62712. 'Ⲇ' => 'ⲇ',
  62713. 'Ⲉ' => 'ⲉ',
  62714. 'Ⲋ' => 'ⲋ',
  62715. 'Ⲍ' => '�',
  62716. 'Ⲏ' => '�',
  62717. '�' => 'ⲑ',
  62718. 'Ⲓ' => 'ⲓ',
  62719. 'Ⲕ' => 'ⲕ',
  62720. 'â²–' => 'â²—',
  62721. 'Ⲙ' => 'ⲙ',
  62722. 'Ⲛ' => 'ⲛ',
  62723. 'Ⲝ' => '�',
  62724. 'Ⲟ' => 'ⲟ',
  62725. 'Ⲡ' => 'ⲡ',
  62726. 'â²¢' => 'â²£',
  62727. 'Ⲥ' => 'ⲥ',
  62728. 'Ⲧ' => 'ⲧ',
  62729. 'Ⲩ' => 'ⲩ',
  62730. 'Ⲫ' => 'ⲫ',
  62731. 'Ⲭ' => 'ⲭ',
  62732. 'Ⲯ' => 'ⲯ',
  62733. 'â²°' => 'â²±',
  62734. 'â²²' => 'â²³',
  62735. 'â²´' => 'â²µ',
  62736. 'Ⲷ' => 'ⲷ',
  62737. 'Ⲹ' => 'ⲹ',
  62738. 'Ⲻ' => 'ⲻ',
  62739. 'â²¼' => 'â²½',
  62740. 'Ⲿ' => 'ⲿ',
  62741. 'Ⳁ' => '�',
  62742. 'Ⳃ' => 'ⳃ',
  62743. 'Ⳅ' => 'ⳅ',
  62744. 'Ⳇ' => 'ⳇ',
  62745. 'Ⳉ' => 'ⳉ',
  62746. 'Ⳋ' => 'ⳋ',
  62747. 'Ⳍ' => '�',
  62748. 'Ⳏ' => '�',
  62749. '�' => 'ⳑ',
  62750. 'Ⳓ' => 'ⳓ',
  62751. 'Ⳕ' => 'ⳕ',
  62752. 'â³–' => 'â³—',
  62753. 'Ⳙ' => 'ⳙ',
  62754. 'Ⳛ' => 'ⳛ',
  62755. 'Ⳝ' => '�',
  62756. 'Ⳟ' => 'ⳟ',
  62757. 'Ⳡ' => 'ⳡ',
  62758. 'â³¢' => 'â³£',
  62759. 'Ⳬ' => 'ⳬ',
  62760. 'â³­' => 'â³®',
  62761. 'â³²' => 'â³³',
  62762. 'Ꙁ' => '�',
  62763. 'Ꙃ' => 'ꙃ',
  62764. 'Ꙅ' => 'ꙅ',
  62765. 'Ꙇ' => 'ꙇ',
  62766. 'Ꙉ' => 'ꙉ',
  62767. 'Ꙋ' => 'ꙋ',
  62768. 'Ꙍ' => '�',
  62769. 'Ꙏ' => '�',
  62770. '�' => 'ꙑ',
  62771. 'Ꙓ' => 'ꙓ',
  62772. 'Ꙕ' => 'ꙕ',
  62773. 'ê™–' => 'ê™—',
  62774. 'Ꙙ' => 'ꙙ',
  62775. 'Ꙛ' => 'ꙛ',
  62776. 'Ꙝ' => '�',
  62777. 'Ꙟ' => 'ꙟ',
  62778. 'Ꙡ' => 'ꙡ',
  62779. 'Ꙣ' => 'ꙣ',
  62780. 'Ꙥ' => 'ꙥ',
  62781. 'Ꙧ' => 'ꙧ',
  62782. 'Ꙩ' => 'ꙩ',
  62783. 'Ꙫ' => 'ꙫ',
  62784. 'Ꙭ' => 'ꙭ',
  62785. 'Ꚁ' => '�',
  62786. 'Ꚃ' => 'ꚃ',
  62787. 'êš„' => 'êš…',
  62788. 'Ꚇ' => 'ꚇ',
  62789. 'Ꚉ' => 'ꚉ',
  62790. 'Ꚋ' => 'ꚋ',
  62791. 'Ꚍ' => '�',
  62792. 'Ꚏ' => '�',
  62793. '�' => 'ꚑ',
  62794. 'êš’' => 'êš“',
  62795. 'êš”' => 'êš•',
  62796. 'êš–' => 'êš—',
  62797. 'Ꚙ' => 'ꚙ',
  62798. 'êšš' => 'êš›',
  62799. 'Ꜣ' => 'ꜣ',
  62800. 'Ꜥ' => 'ꜥ',
  62801. 'Ꜧ' => 'ꜧ',
  62802. 'Ꜩ' => 'ꜩ',
  62803. 'Ꜫ' => 'ꜫ',
  62804. 'Ꜭ' => 'ꜭ',
  62805. 'Ꜯ' => 'ꜯ',
  62806. 'Ꜳ' => 'ꜳ',
  62807. 'Ꜵ' => 'ꜵ',
  62808. 'Ꜷ' => 'ꜷ',
  62809. 'Ꜹ' => 'ꜹ',
  62810. 'Ꜻ' => 'ꜻ',
  62811. 'Ꜽ' => 'ꜽ',
  62812. 'Ꜿ' => 'ꜿ',
  62813. '�' => '�',
  62814. '�' => '�',
  62815. '�' => '�',
  62816. '�' => '�',
  62817. '�' => '�',
  62818. '�' => '�',
  62819. '�' => '�',
  62820. '�' => '�',
  62821. '�' => '�',
  62822. '�' => '�',
  62823. '�' => '�',
  62824. '�' => '�',
  62825. '�' => '�',
  62826. '�' => '�',
  62827. '�' => '�',
  62828. '�' => '�',
  62829. '�' => '�',
  62830. '�' => '�',
  62831. '�' => '�',
  62832. '�' => '�',
  62833. '�' => '�',
  62834. '�' => '�',
  62835. '�' => '�',
  62836. '�' => '�',
  62837. '�' => '�',
  62838. '�' => '�',
  62839. '�' => 'ᵹ',
  62840. '�' => '�',
  62841. 'Ꞁ' => '�',
  62842. 'Ꞃ' => 'ꞃ',
  62843. 'êž„' => 'êž…',
  62844. 'Ꞇ' => 'ꞇ',
  62845. 'Ꞌ' => 'ꞌ',
  62846. '�' => 'ɥ',
  62847. '�' => 'ꞑ',
  62848. 'êž’' => 'êž“',
  62849. 'êž–' => 'êž—',
  62850. 'Ꞙ' => 'ꞙ',
  62851. 'êžš' => 'êž›',
  62852. 'Ꞝ' => '�',
  62853. 'Ꞟ' => 'ꞟ',
  62854. 'êž ' => 'êž¡',
  62855. 'Ꞣ' => 'ꞣ',
  62856. 'Ꞥ' => 'ꞥ',
  62857. 'Ꞧ' => 'ꞧ',
  62858. 'Ꞩ' => 'ꞩ',
  62859. 'Ɦ' => 'ɦ',
  62860. 'Ɜ' => 'ɜ',
  62861. 'Ɡ' => 'ɡ',
  62862. 'Ɬ' => 'ɬ',
  62863. 'Ɪ' => 'ɪ',
  62864. 'êž°' => 'Êž',
  62865. 'Ʇ' => 'ʇ',
  62866. 'Ʝ' => '�',
  62867. 'êž³' => 'ê­“',
  62868. 'êž´' => 'êžµ',
  62869. 'Ꞷ' => 'ꞷ',
  62870. 'Ꞹ' => 'ꞹ',
  62871. 'Ꞻ' => 'ꞻ',
  62872. 'êž¼' => 'êž½',
  62873. 'êž¾' => 'êž¿',
  62874. 'Ꟃ' => 'ꟃ',
  62875. 'Ꞔ' => 'ꞔ',
  62876. 'Ʂ' => 'ʂ',
  62877. 'Ᶎ' => 'ᶎ',
  62878. 'Ꟈ' => 'ꟈ',
  62879. 'Ꟊ' => 'ꟊ',
  62880. 'Ꟶ' => 'ꟶ',
  62881. 'A' => '�',
  62882. 'B' => 'b',
  62883. 'C' => 'c',
  62884. 'D' => 'd',
  62885. 'ï¼¥' => 'ï½…',
  62886. 'F' => 'f',
  62887. 'G' => 'g',
  62888. 'H' => 'h',
  62889. 'I' => 'i',
  62890. 'J' => 'j',
  62891. 'K' => 'k',
  62892. 'L' => 'l',
  62893. 'M' => '�',
  62894. 'N' => 'n',
  62895. 'O' => '�',
  62896. 'P' => '�',
  62897. 'Q' => 'q',
  62898. 'ï¼²' => 'ï½’',
  62899. 'S' => 's',
  62900. 'ï¼´' => 'ï½”',
  62901. 'U' => 'u',
  62902. 'V' => 'v',
  62903. 'ï¼·' => 'ï½—',
  62904. 'X' => 'x',
  62905. 'ï¼¹' => 'ï½™',
  62906. 'Z' => 'z',
  62907. '�' => '�',
  62908. '�' => '�',
  62909. '�' => '�',
  62910. '�' => '�',
  62911. '�' => '�',
  62912. '�' => '�',
  62913. '�' => '�',
  62914. '�' => '�',
  62915. '�' => '�',
  62916. '�' => '�',
  62917. '�' => '�',
  62918. '�' => '�',
  62919. '�' => '�',
  62920. '�' => '�',
  62921. '�' => '�',
  62922. '�' => '�',
  62923. '�' => '�',
  62924. '�' => '�',
  62925. '�' => '�',
  62926. '�' => '�',
  62927. '�' => '�',
  62928. '�' => '�',
  62929. '�' => '�',
  62930. '�' => '�',
  62931. '�' => '�',
  62932. '�' => '�',
  62933. '�' => '�',
  62934. '�' => '�',
  62935. '�' => '�',
  62936. '�' => '�',
  62937. '�' => '�',
  62938. '�' => '�',
  62939. '�' => '�',
  62940. '�' => '�',
  62941. '�' => '�',
  62942. '�' => '�',
  62943. '�' => '�',
  62944. '�' => '�',
  62945. '�' => '�',
  62946. '�' => '�',
  62947. '�' => '�',
  62948. '�' => '�',
  62949. '�' => '�',
  62950. '�' => '�',
  62951. '�' => '�',
  62952. '�' => '�',
  62953. '�' => '�',
  62954. '�' => '�',
  62955. '�' => '�',
  62956. '�' => '�',
  62957. '�' => '�',
  62958. '�' => '�',
  62959. '�' => '�',
  62960. '�' => '�',
  62961. '�' => '�',
  62962. '�' => '�',
  62963. '�' => '�',
  62964. '�' => '�',
  62965. '�' => '�',
  62966. '�' => '�',
  62967. '�' => '�',
  62968. '�' => '�',
  62969. '�' => '�',
  62970. '�' => '�',
  62971. '�' => '�',
  62972. '�' => '�',
  62973. '�' => '�',
  62974. '�' => '�',
  62975. '�' => '�',
  62976. '�' => '�',
  62977. '�' => '�',
  62978. '�' => '�',
  62979. '�' => '�',
  62980. '�' => '�',
  62981. '�' => '�',
  62982. '�' => '�',
  62983. '�' => '�',
  62984. '�' => '�',
  62985. '�' => '�',
  62986. '�' => '�',
  62987. '�' => '�',
  62988. '�' => '�',
  62989. '�' => '�',
  62990. '�' => '�',
  62991. '�' => '�',
  62992. '�' => '�',
  62993. '�' => '�',
  62994. '�' => '�',
  62995. '�' => '�',
  62996. '�' => '�',
  62997. '�' => '�',
  62998. '�' => '�',
  62999. '�' => '�',
  63000. '�' => '�',
  63001. '�' => '�',
  63002. '�' => '�',
  63003. '�' => '�',
  63004. '�' => '�',
  63005. '�' => '�',
  63006. '�' => '�',
  63007. '�' => '�',
  63008. '�' => '�',
  63009. '�' => '�',
  63010. '�' => '�',
  63011. '�' => '�',
  63012. '�' => '�',
  63013. '�' => '�',
  63014. '�' => '�',
  63015. '�' => '�',
  63016. '�' => '�',
  63017. '�' => '�',
  63018. '�' => '�',
  63019. '�' => '�',
  63020. '�' => '�',
  63021. '�' => '�',
  63022. '�' => '�',
  63023. '�' => '�',
  63024. '�' => '�',
  63025. '�' => '�',
  63026. '�' => '�',
  63027. '�' => '�',
  63028. '�' => '�',
  63029. '�' => '�',
  63030. '�' => '�',
  63031. '�' => '�',
  63032. '�' => '�',
  63033. '�' => '�',
  63034. 'ð‘¢ ' => 'ð‘£€',
  63035. '𑢡' => '�',
  63036. '𑢢' => '𑣂',
  63037. '𑢣' => '𑣃',
  63038. '𑢤' => '𑣄',
  63039. 'ð‘¢¥' => 'ð‘£…',
  63040. '𑢦' => '𑣆',
  63041. '𑢧' => '𑣇',
  63042. '𑢨' => '𑣈',
  63043. '𑢩' => '𑣉',
  63044. '𑢪' => '𑣊',
  63045. '𑢫' => '𑣋',
  63046. '𑢬' => '𑣌',
  63047. '𑢭' => '�',
  63048. '𑢮' => '𑣎',
  63049. '𑢯' => '�',
  63050. '𑢰' => '�',
  63051. '𑢱' => '𑣑',
  63052. 'ð‘¢²' => 'ð‘£’',
  63053. '𑢳' => '𑣓',
  63054. 'ð‘¢´' => 'ð‘£”',
  63055. '𑢵' => '𑣕',
  63056. '𑢶' => '𑣖',
  63057. 'ð‘¢·' => 'ð‘£—',
  63058. '𑢸' => '𑣘',
  63059. 'ð‘¢¹' => 'ð‘£™',
  63060. '𑢺' => '𑣚',
  63061. 'ð‘¢»' => 'ð‘£›',
  63062. '𑢼' => '𑣜',
  63063. '𑢽' => '�',
  63064. '𑢾' => '𑣞',
  63065. '𑢿' => '𑣟',
  63066. 'ð–¹€' => 'ð–¹ ',
  63067. '�' => '𖹡',
  63068. '𖹂' => '𖹢',
  63069. '𖹃' => '𖹣',
  63070. '𖹄' => '𖹤',
  63071. 'ð–¹…' => 'ð–¹¥',
  63072. '𖹆' => '𖹦',
  63073. '𖹇' => '𖹧',
  63074. '𖹈' => '𖹨',
  63075. '𖹉' => '𖹩',
  63076. '𖹊' => '𖹪',
  63077. '𖹋' => '𖹫',
  63078. '𖹌' => '𖹬',
  63079. '�' => '𖹭',
  63080. '𖹎' => '𖹮',
  63081. '�' => '𖹯',
  63082. '�' => '𖹰',
  63083. '𖹑' => '𖹱',
  63084. 'ð–¹’' => 'ð–¹²',
  63085. '𖹓' => '𖹳',
  63086. 'ð–¹”' => 'ð–¹´',
  63087. '𖹕' => '𖹵',
  63088. '𖹖' => '𖹶',
  63089. 'ð–¹—' => 'ð–¹·',
  63090. '𖹘' => '𖹸',
  63091. 'ð–¹™' => 'ð–¹¹',
  63092. '𖹚' => '𖹺',
  63093. 'ð–¹›' => 'ð–¹»',
  63094. '𖹜' => '𖹼',
  63095. '�' => '𖹽',
  63096. '𖹞' => '𖹾',
  63097. '𖹟' => '𖹿',
  63098. '𞤀' => '𞤢',
  63099. '�' => '𞤣',
  63100. '𞤂' => '𞤤',
  63101. '𞤃' => '𞤥',
  63102. '𞤄' => '𞤦',
  63103. '𞤅' => '𞤧',
  63104. '𞤆' => '𞤨',
  63105. '𞤇' => '𞤩',
  63106. '𞤈' => '𞤪',
  63107. '𞤉' => '𞤫',
  63108. '𞤊' => '𞤬',
  63109. '𞤋' => '𞤭',
  63110. '𞤌' => '𞤮',
  63111. '�' => '𞤯',
  63112. '𞤎' => '𞤰',
  63113. '�' => '𞤱',
  63114. '�' => '𞤲',
  63115. '𞤑' => '𞤳',
  63116. '𞤒' => '𞤴',
  63117. '𞤓' => '𞤵',
  63118. '𞤔' => '𞤶',
  63119. '𞤕' => '𞤷',
  63120. '𞤖' => '𞤸',
  63121. '𞤗' => '𞤹',
  63122. '𞤘' => '𞤺',
  63123. '𞤙' => '𞤻',
  63124. '𞤚' => '𞤼',
  63125. '𞤛' => '𞤽',
  63126. '𞤜' => '𞤾',
  63127. '�' => '𞤿',
  63128. '𞤞' => '𞥀',
  63129. '𞤟' => '�',
  63130. '𞤠' => '𞥂',
  63131. '𞤡' => '𞥃',
  63132. );
  63133. <?php
  63134. 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';
  63135. <?php
  63136. return array (
  63137. 'a' => 'A',
  63138. 'b' => 'B',
  63139. 'c' => 'C',
  63140. 'd' => 'D',
  63141. 'e' => 'E',
  63142. 'f' => 'F',
  63143. 'g' => 'G',
  63144. 'h' => 'H',
  63145. 'i' => 'I',
  63146. 'j' => 'J',
  63147. 'k' => 'K',
  63148. 'l' => 'L',
  63149. 'm' => 'M',
  63150. 'n' => 'N',
  63151. 'o' => 'O',
  63152. 'p' => 'P',
  63153. 'q' => 'Q',
  63154. 'r' => 'R',
  63155. 's' => 'S',
  63156. 't' => 'T',
  63157. 'u' => 'U',
  63158. 'v' => 'V',
  63159. 'w' => 'W',
  63160. 'x' => 'X',
  63161. 'y' => 'Y',
  63162. 'z' => 'Z',
  63163. 'µ' => 'Μ',
  63164. 'à' => 'À',
  63165. 'á' => '�',
  63166. 'â' => 'Â',
  63167. 'ã' => 'Ã',
  63168. 'ä' => 'Ä',
  63169. 'Ã¥' => 'Ã…',
  63170. 'æ' => 'Æ',
  63171. 'ç' => 'Ç',
  63172. 'è' => 'È',
  63173. 'é' => 'É',
  63174. 'ê' => 'Ê',
  63175. 'ë' => 'Ë',
  63176. 'ì' => 'Ì',
  63177. 'í' => '�',
  63178. 'î' => 'Î',
  63179. 'ï' => '�',
  63180. 'ð' => '�',
  63181. 'ñ' => 'Ñ',
  63182. 'ò' => 'Ò',
  63183. 'ó' => 'Ó',
  63184. 'ô' => 'Ô',
  63185. 'õ' => 'Õ',
  63186. 'ö' => 'Ö',
  63187. 'ø' => 'Ø',
  63188. 'ù' => 'Ù',
  63189. 'ú' => 'Ú',
  63190. 'û' => 'Û',
  63191. 'ü' => 'Ü',
  63192. 'ý' => '�',
  63193. 'þ' => 'Þ',
  63194. 'ÿ' => 'Ÿ',
  63195. '�' => 'Ā',
  63196. 'ă' => 'Ă',
  63197. 'Ä…' => 'Ä„',
  63198. 'ć' => 'Ć',
  63199. 'ĉ' => 'Ĉ',
  63200. 'Ä‹' => 'ÄŠ',
  63201. '�' => 'Č',
  63202. '�' => 'Ď',
  63203. 'đ' => '�',
  63204. 'Ä“' => 'Ä’',
  63205. 'Ä•' => 'Ä”',
  63206. 'Ä—' => 'Ä–',
  63207. 'ę' => 'Ę',
  63208. 'Ä›' => 'Äš',
  63209. '�' => 'Ĝ',
  63210. 'ÄŸ' => 'Äž',
  63211. 'Ä¡' => 'Ä ',
  63212. 'Ä£' => 'Ä¢',
  63213. 'ĥ' => 'Ĥ',
  63214. 'ħ' => 'Ħ',
  63215. 'ĩ' => 'Ĩ',
  63216. 'ī' => 'Ī',
  63217. 'ĭ' => 'Ĭ',
  63218. 'į' => 'Į',
  63219. 'ı' => 'I',
  63220. 'ij' => 'IJ',
  63221. 'ĵ' => 'Ĵ',
  63222. 'ķ' => 'Ķ',
  63223. 'ĺ' => 'Ĺ',
  63224. 'ļ' => 'Ļ',
  63225. 'ľ' => 'Ľ',
  63226. 'Å€' => 'Ä¿',
  63227. 'ł' => '�',
  63228. 'ń' => 'Ń',
  63229. 'ņ' => 'Ņ',
  63230. 'ň' => 'Ň',
  63231. 'Å‹' => 'ÅŠ',
  63232. '�' => 'Ō',
  63233. '�' => 'Ŏ',
  63234. 'ő' => '�',
  63235. 'Å“' => 'Å’',
  63236. 'Å•' => 'Å”',
  63237. 'Å—' => 'Å–',
  63238. 'ř' => 'Ř',
  63239. 'Å›' => 'Åš',
  63240. '�' => 'Ŝ',
  63241. 'ÅŸ' => 'Åž',
  63242. 'Å¡' => 'Å ',
  63243. 'Å£' => 'Å¢',
  63244. 'ť' => 'Ť',
  63245. 'ŧ' => 'Ŧ',
  63246. 'ũ' => 'Ũ',
  63247. 'ū' => 'Ū',
  63248. 'ŭ' => 'Ŭ',
  63249. 'ů' => 'Ů',
  63250. 'ű' => 'Ű',
  63251. 'ų' => 'Ų',
  63252. 'ŵ' => 'Ŵ',
  63253. 'ŷ' => 'Ŷ',
  63254. 'ź' => 'Ź',
  63255. 'ż' => 'Ż',
  63256. 'ž' => 'Ž',
  63257. 'Å¿' => 'S',
  63258. 'ƀ' => 'Ƀ',
  63259. 'ƃ' => 'Ƃ',
  63260. 'Æ…' => 'Æ„',
  63261. 'ƈ' => 'Ƈ',
  63262. 'ƌ' => 'Ƌ',
  63263. 'Æ’' => 'Æ‘',
  63264. 'ƕ' => 'Ƕ',
  63265. 'ƙ' => 'Ƙ',
  63266. 'ƚ' => 'Ƚ',
  63267. 'Æž' => 'È ',
  63268. 'Æ¡' => 'Æ ',
  63269. 'Æ£' => 'Æ¢',
  63270. 'ƥ' => 'Ƥ',
  63271. 'ƨ' => 'Ƨ',
  63272. 'ƭ' => 'Ƭ',
  63273. 'ư' => 'Ư',
  63274. 'ƴ' => 'Ƴ',
  63275. 'ƶ' => 'Ƶ',
  63276. 'ƹ' => 'Ƹ',
  63277. 'ƽ' => 'Ƽ',
  63278. 'Æ¿' => 'Ç·',
  63279. 'Ç…' => 'Ç„',
  63280. 'dž' => 'DŽ',
  63281. 'Lj' => 'LJ',
  63282. 'lj' => 'LJ',
  63283. 'Ç‹' => 'ÇŠ',
  63284. 'nj' => 'NJ',
  63285. 'ǎ' => '�',
  63286. '�' => '�',
  63287. 'Ç’' => 'Ç‘',
  63288. 'Ç”' => 'Ç“',
  63289. 'Ç–' => 'Ç•',
  63290. 'ǘ' => 'Ǘ',
  63291. 'Çš' => 'Ç™',
  63292. 'ǜ' => 'Ǜ',
  63293. '�' => 'Ǝ',
  63294. 'ÇŸ' => 'Çž',
  63295. 'Ç¡' => 'Ç ',
  63296. 'Ç£' => 'Ç¢',
  63297. 'ǥ' => 'Ǥ',
  63298. 'ǧ' => 'Ǧ',
  63299. 'ǩ' => 'Ǩ',
  63300. 'ǫ' => 'Ǫ',
  63301. 'ǭ' => 'Ǭ',
  63302. 'ǯ' => 'Ǯ',
  63303. 'Dz' => 'DZ',
  63304. 'dz' => 'DZ',
  63305. 'ǵ' => 'Ǵ',
  63306. 'ǹ' => 'Ǹ',
  63307. 'ǻ' => 'Ǻ',
  63308. 'ǽ' => 'Ǽ',
  63309. 'ǿ' => 'Ǿ',
  63310. '�' => 'Ȁ',
  63311. 'ȃ' => 'Ȃ',
  63312. 'È…' => 'È„',
  63313. 'ȇ' => 'Ȇ',
  63314. 'ȉ' => 'Ȉ',
  63315. 'È‹' => 'ÈŠ',
  63316. '�' => 'Ȍ',
  63317. '�' => 'Ȏ',
  63318. 'ȑ' => '�',
  63319. 'È“' => 'È’',
  63320. 'È•' => 'È”',
  63321. 'È—' => 'È–',
  63322. 'ș' => 'Ș',
  63323. 'È›' => 'Èš',
  63324. '�' => 'Ȝ',
  63325. 'ÈŸ' => 'Èž',
  63326. 'È£' => 'È¢',
  63327. 'ȥ' => 'Ȥ',
  63328. 'ȧ' => 'Ȧ',
  63329. 'ȩ' => 'Ȩ',
  63330. 'ȫ' => 'Ȫ',
  63331. 'ȭ' => 'Ȭ',
  63332. 'ȯ' => 'Ȯ',
  63333. 'ȱ' => 'Ȱ',
  63334. 'ȳ' => 'Ȳ',
  63335. 'ȼ' => 'Ȼ',
  63336. 'È¿' => 'â±¾',
  63337. 'ɀ' => 'Ɀ',
  63338. 'ɂ' => '�',
  63339. 'ɇ' => 'Ɇ',
  63340. 'ɉ' => 'Ɉ',
  63341. 'É‹' => 'ÉŠ',
  63342. '�' => 'Ɍ',
  63343. '�' => 'Ɏ',
  63344. '�' => 'Ɐ',
  63345. 'É‘' => 'â±­',
  63346. 'É’' => 'â±°',
  63347. 'ɓ' => '�',
  63348. 'ɔ' => 'Ɔ',
  63349. 'ɖ' => 'Ɖ',
  63350. 'É—' => 'ÆŠ',
  63351. 'ə' => '�',
  63352. 'ɛ' => '�',
  63353. 'ɜ' => 'Ɜ',
  63354. 'É ' => 'Æ“',
  63355. 'ɡ' => 'Ɡ',
  63356. 'É£' => 'Æ”',
  63357. 'ɥ' => '�',
  63358. 'ɦ' => 'Ɦ',
  63359. 'ɨ' => 'Ɨ',
  63360. 'É©' => 'Æ–',
  63361. 'ɪ' => 'Ɪ',
  63362. 'É«' => 'â±¢',
  63363. 'ɬ' => 'Ɬ',
  63364. 'ɯ' => 'Ɯ',
  63365. 'ɱ' => 'Ɱ',
  63366. 'ɲ' => '�',
  63367. 'ɵ' => 'Ɵ',
  63368. 'ɽ' => 'Ɽ',
  63369. 'ʀ' => 'Ʀ',
  63370. 'ʂ' => 'Ʂ',
  63371. 'ʃ' => 'Ʃ',
  63372. 'ʇ' => 'Ʇ',
  63373. 'ʈ' => 'Ʈ',
  63374. 'ʉ' => 'Ʉ',
  63375. 'ʊ' => 'Ʊ',
  63376. 'ʋ' => 'Ʋ',
  63377. 'ʌ' => 'Ʌ',
  63378. 'Ê’' => 'Æ·',
  63379. '�' => 'Ʝ',
  63380. 'Êž' => 'êž°',
  63381. 'ͅ' => 'Ι',
  63382. 'ͱ' => 'Ͱ',
  63383. 'ͳ' => 'Ͳ',
  63384. 'ͷ' => 'Ͷ',
  63385. 'ͻ' => 'Ͻ',
  63386. 'ͼ' => 'Ͼ',
  63387. 'ͽ' => 'Ͽ',
  63388. 'ά' => 'Ά',
  63389. 'έ' => 'Έ',
  63390. 'ή' => 'Ή',
  63391. 'ί' => 'Ί',
  63392. 'α' => 'Α',
  63393. 'β' => 'Β',
  63394. 'γ' => 'Γ',
  63395. 'δ' => 'Δ',
  63396. 'ε' => 'Ε',
  63397. 'ζ' => 'Ζ',
  63398. 'η' => 'Η',
  63399. 'θ' => 'Θ',
  63400. 'ι' => 'Ι',
  63401. 'κ' => 'Κ',
  63402. 'λ' => 'Λ',
  63403. 'μ' => 'Μ',
  63404. 'ν' => '�',
  63405. 'ξ' => 'Ξ',
  63406. 'ο' => 'Ο',
  63407. 'π' => 'Π',
  63408. '�' => 'Ρ',
  63409. 'ς' => 'Σ',
  63410. 'σ' => 'Σ',
  63411. 'τ' => 'Τ',
  63412. 'Ï…' => 'Î¥',
  63413. 'φ' => 'Φ',
  63414. 'χ' => 'Χ',
  63415. 'ψ' => 'Ψ',
  63416. 'ω' => 'Ω',
  63417. 'ϊ' => 'Ϊ',
  63418. 'ϋ' => 'Ϋ',
  63419. 'ό' => 'Ό',
  63420. '�' => 'Ύ',
  63421. 'ώ' => '�',
  63422. '�' => 'Β',
  63423. 'ϑ' => 'Θ',
  63424. 'ϕ' => 'Φ',
  63425. 'ϖ' => 'Π',
  63426. 'ϗ' => '�',
  63427. 'ϙ' => 'Ϙ',
  63428. 'Ï›' => 'Ïš',
  63429. '�' => 'Ϝ',
  63430. 'ÏŸ' => 'Ïž',
  63431. 'Ï¡' => 'Ï ',
  63432. 'Ï£' => 'Ï¢',
  63433. 'ϥ' => 'Ϥ',
  63434. 'ϧ' => 'Ϧ',
  63435. 'ϩ' => 'Ϩ',
  63436. 'ϫ' => 'Ϫ',
  63437. 'ϭ' => 'Ϭ',
  63438. 'ϯ' => 'Ϯ',
  63439. 'ϰ' => 'Κ',
  63440. 'ϱ' => 'Ρ',
  63441. 'ϲ' => 'Ϲ',
  63442. 'ϳ' => 'Ϳ',
  63443. 'ϵ' => 'Ε',
  63444. 'ϸ' => 'Ϸ',
  63445. 'ϻ' => 'Ϻ',
  63446. 'а' => '�',
  63447. 'б' => 'Б',
  63448. 'в' => 'В',
  63449. 'г' => 'Г',
  63450. 'д' => 'Д',
  63451. 'е' => 'Е',
  63452. 'ж' => 'Ж',
  63453. 'з' => 'З',
  63454. 'и' => 'И',
  63455. 'й' => 'Й',
  63456. 'к' => 'К',
  63457. 'л' => 'Л',
  63458. 'м' => 'М',
  63459. 'н' => '�',
  63460. 'о' => 'О',
  63461. 'п' => 'П',
  63462. 'р' => 'Р',
  63463. '�' => 'С',
  63464. 'т' => 'Т',
  63465. 'у' => 'У',
  63466. 'ф' => 'Ф',
  63467. 'Ñ…' => 'Ð¥',
  63468. 'ц' => 'Ц',
  63469. 'ч' => 'Ч',
  63470. 'ш' => 'Ш',
  63471. 'щ' => 'Щ',
  63472. 'ъ' => 'Ъ',
  63473. 'ы' => 'Ы',
  63474. 'ь' => 'Ь',
  63475. '�' => 'Э',
  63476. 'ю' => 'Ю',
  63477. '�' => 'Я',
  63478. '�' => 'Ѐ',
  63479. 'ё' => '�',
  63480. 'ђ' => 'Ђ',
  63481. 'ѓ' => 'Ѓ',
  63482. 'є' => 'Є',
  63483. 'Ñ•' => 'Ð…',
  63484. 'і' => 'І',
  63485. 'ї' => 'Ї',
  63486. 'ј' => 'Ј',
  63487. 'љ' => 'Љ',
  63488. 'њ' => 'Њ',
  63489. 'ћ' => 'Ћ',
  63490. 'ќ' => 'Ќ',
  63491. '�' => '�',
  63492. 'Ñž' => 'ÐŽ',
  63493. 'џ' => '�',
  63494. 'Ñ¡' => 'Ñ ',
  63495. 'Ñ£' => 'Ñ¢',
  63496. 'ѥ' => 'Ѥ',
  63497. 'ѧ' => 'Ѧ',
  63498. 'ѩ' => 'Ѩ',
  63499. 'ѫ' => 'Ѫ',
  63500. 'ѭ' => 'Ѭ',
  63501. 'ѯ' => 'Ѯ',
  63502. 'ѱ' => 'Ѱ',
  63503. 'ѳ' => 'Ѳ',
  63504. 'ѵ' => 'Ѵ',
  63505. 'ѷ' => 'Ѷ',
  63506. 'ѹ' => 'Ѹ',
  63507. 'ѻ' => 'Ѻ',
  63508. 'ѽ' => 'Ѽ',
  63509. 'ѿ' => 'Ѿ',
  63510. 'Ò�' => 'Ò€',
  63511. 'Ò‹' => 'ÒŠ',
  63512. '�' => 'Ҍ',
  63513. 'Ò�' => 'ÒŽ',
  63514. 'Ò‘' => 'Ò�',
  63515. 'Ò“' => 'Ò’',
  63516. 'Ò•' => 'Ò”',
  63517. 'Ò—' => 'Ò–',
  63518. 'Ò™' => 'Ò˜',
  63519. 'Ò›' => 'Òš',
  63520. '�' => 'Ҝ',
  63521. 'ÒŸ' => 'Òž',
  63522. 'Ò¡' => 'Ò ',
  63523. 'Ò£' => 'Ò¢',
  63524. 'Ò¥' => 'Ò¤',
  63525. 'Ò§' => 'Ò¦',
  63526. 'Ò©' => 'Ò¨',
  63527. 'Ò«' => 'Òª',
  63528. 'Ò­' => 'Ò¬',
  63529. 'Ò¯' => 'Ò®',
  63530. 'Ò±' => 'Ò°',
  63531. 'Ò³' => 'Ò²',
  63532. 'Òµ' => 'Ò´',
  63533. 'Ò·' => 'Ò¶',
  63534. 'Ò¹' => 'Ò¸',
  63535. 'Ò»' => 'Òº',
  63536. 'Ò½' => 'Ò¼',
  63537. 'Ò¿' => 'Ò¾',
  63538. 'Ó‚' => 'Ó�',
  63539. 'Ó„' => 'Óƒ',
  63540. 'Ó†' => 'Ó…',
  63541. 'Óˆ' => 'Ó‡',
  63542. 'ÓŠ' => 'Ó‰',
  63543. 'ӌ' => 'Ӌ',
  63544. 'ÓŽ' => 'Ó�',
  63545. 'Ó�' => 'Ó€',
  63546. 'Ó‘' => 'Ó�',
  63547. 'Ó“' => 'Ó’',
  63548. 'Ó•' => 'Ó”',
  63549. 'Ó—' => 'Ó–',
  63550. 'Ó™' => 'Ó˜',
  63551. 'Ó›' => 'Óš',
  63552. '�' => 'Ӝ',
  63553. 'ÓŸ' => 'Óž',
  63554. 'Ó¡' => 'Ó ',
  63555. 'Ó£' => 'Ó¢',
  63556. 'Ó¥' => 'Ó¤',
  63557. 'Ó§' => 'Ó¦',
  63558. 'Ó©' => 'Ó¨',
  63559. 'Ó«' => 'Óª',
  63560. 'Ó­' => 'Ó¬',
  63561. 'Ó¯' => 'Ó®',
  63562. 'Ó±' => 'Ó°',
  63563. 'Ó³' => 'Ó²',
  63564. 'Óµ' => 'Ó´',
  63565. 'Ó·' => 'Ó¶',
  63566. 'Ó¹' => 'Ó¸',
  63567. 'Ó»' => 'Óº',
  63568. 'Ó½' => 'Ó¼',
  63569. 'Ó¿' => 'Ó¾',
  63570. 'Ô�' => 'Ô€',
  63571. 'Ôƒ' => 'Ô‚',
  63572. 'Ô…' => 'Ô„',
  63573. 'Ô‡' => 'Ô†',
  63574. 'Ô‰' => 'Ôˆ',
  63575. 'Ô‹' => 'ÔŠ',
  63576. '�' => 'Ԍ',
  63577. 'Ô�' => 'ÔŽ',
  63578. 'Ô‘' => 'Ô�',
  63579. 'Ô“' => 'Ô’',
  63580. 'Ô•' => 'Ô”',
  63581. 'Ô—' => 'Ô–',
  63582. 'Ô™' => 'Ô˜',
  63583. 'Ô›' => 'Ôš',
  63584. '�' => 'Ԝ',
  63585. 'ÔŸ' => 'Ôž',
  63586. 'Ô¡' => 'Ô ',
  63587. 'Ô£' => 'Ô¢',
  63588. 'Ô¥' => 'Ô¤',
  63589. 'Ô§' => 'Ô¦',
  63590. 'Ô©' => 'Ô¨',
  63591. 'Ô«' => 'Ôª',
  63592. 'Ô­' => 'Ô¬',
  63593. 'Ô¯' => 'Ô®',
  63594. 'Õ¡' => 'Ô±',
  63595. 'Õ¢' => 'Ô²',
  63596. 'Õ£' => 'Ô³',
  63597. 'Õ¤' => 'Ô´',
  63598. 'Õ¥' => 'Ôµ',
  63599. 'Õ¦' => 'Ô¶',
  63600. 'Õ§' => 'Ô·',
  63601. 'Õ¨' => 'Ô¸',
  63602. 'Õ©' => 'Ô¹',
  63603. 'Õª' => 'Ôº',
  63604. 'Õ«' => 'Ô»',
  63605. 'Õ¬' => 'Ô¼',
  63606. 'Õ­' => 'Ô½',
  63607. 'Õ®' => 'Ô¾',
  63608. 'Õ¯' => 'Ô¿',
  63609. 'Õ°' => 'Õ€',
  63610. 'Õ±' => 'Õ�',
  63611. 'Õ²' => 'Õ‚',
  63612. 'Õ³' => 'Õƒ',
  63613. 'Õ´' => 'Õ„',
  63614. 'Õµ' => 'Õ…',
  63615. 'Õ¶' => 'Õ†',
  63616. 'Õ·' => 'Õ‡',
  63617. 'Õ¸' => 'Õˆ',
  63618. 'Õ¹' => 'Õ‰',
  63619. 'Õº' => 'ÕŠ',
  63620. 'Õ»' => 'Õ‹',
  63621. 'ռ' => 'Ռ',
  63622. 'Õ½' => 'Õ�',
  63623. 'Õ¾' => 'ÕŽ',
  63624. 'Õ¿' => 'Õ�',
  63625. 'Ö€' => 'Õ�',
  63626. 'Ö�' => 'Õ‘',
  63627. 'Ö‚' => 'Õ’',
  63628. 'Öƒ' => 'Õ“',
  63629. 'Ö„' => 'Õ”',
  63630. 'Ö…' => 'Õ•',
  63631. 'Ö†' => 'Õ–',
  63632. '�' => '�',
  63633. 'ბ' => 'Ბ',
  63634. 'გ' => 'Გ',
  63635. 'დ' => 'Დ',
  63636. 'ე' => 'Ე',
  63637. 'ვ' => 'Ვ',
  63638. 'ზ' => 'Ზ',
  63639. 'თ' => 'Თ',
  63640. 'ი' => 'Ი',
  63641. 'კ' => 'Კ',
  63642. 'ლ' => 'Ლ',
  63643. 'მ' => 'Მ',
  63644. 'ნ' => 'Ნ',
  63645. '�' => '�',
  63646. 'პ' => 'Პ',
  63647. 'ჟ' => 'Ჟ',
  63648. 'რ' => 'Რ',
  63649. 'ს' => 'Ს',
  63650. 'ტ' => 'Ტ',
  63651. 'უ' => 'Უ',
  63652. 'ფ' => 'Ფ',
  63653. 'ქ' => 'Ქ',
  63654. 'ღ' => 'Ღ',
  63655. 'ყ' => 'Ყ',
  63656. 'შ' => 'Შ',
  63657. 'ჩ' => 'Ჩ',
  63658. 'ც' => 'Ც',
  63659. 'ძ' => 'Ძ',
  63660. 'წ' => 'Წ',
  63661. 'ჭ' => 'Ჭ',
  63662. 'ხ' => 'Ხ',
  63663. 'ჯ' => 'Ჯ',
  63664. 'ჰ' => 'Ჰ',
  63665. 'ჱ' => 'Ჱ',
  63666. 'ჲ' => 'Ჲ',
  63667. 'ჳ' => 'Ჳ',
  63668. 'ჴ' => 'Ჴ',
  63669. 'ჵ' => 'Ჵ',
  63670. 'ჶ' => 'Ჶ',
  63671. 'ჷ' => 'Ჷ',
  63672. 'ჸ' => 'Ჸ',
  63673. 'ჹ' => 'Ჹ',
  63674. 'ჺ' => 'Ჺ',
  63675. 'ჽ' => 'Ჽ',
  63676. 'ჾ' => 'Ჾ',
  63677. 'ჿ' => 'Ჿ',
  63678. '�' => '�',
  63679. '�' => '�',
  63680. '�' => '�',
  63681. '�' => '�',
  63682. '�' => '�',
  63683. '�' => '�',
  63684. 'á²€' => 'Ð’',
  63685. '�' => 'Д',
  63686. 'ᲂ' => 'О',
  63687. 'ᲃ' => 'С',
  63688. 'ᲄ' => 'Т',
  63689. 'ᲅ' => 'Т',
  63690. 'ᲆ' => 'Ъ',
  63691. 'ᲇ' => 'Ѣ',
  63692. 'ᲈ' => 'Ꙋ',
  63693. 'ᵹ' => '�',
  63694. 'áµ½' => 'â±£',
  63695. 'ᶎ' => 'Ᶎ',
  63696. '�' => 'Ḁ',
  63697. 'ḃ' => 'Ḃ',
  63698. 'ḅ' => 'Ḅ',
  63699. 'ḇ' => 'Ḇ',
  63700. 'ḉ' => 'Ḉ',
  63701. 'ḋ' => 'Ḋ',
  63702. '�' => 'Ḍ',
  63703. '�' => 'Ḏ',
  63704. 'ḑ' => '�',
  63705. 'ḓ' => 'Ḓ',
  63706. 'ḕ' => 'Ḕ',
  63707. 'ḗ' => 'Ḗ',
  63708. 'ḙ' => 'Ḙ',
  63709. 'ḛ' => 'Ḛ',
  63710. '�' => 'Ḝ',
  63711. 'ḟ' => 'Ḟ',
  63712. 'ḡ' => 'Ḡ',
  63713. 'ḣ' => 'Ḣ',
  63714. 'ḥ' => 'Ḥ',
  63715. 'ḧ' => 'Ḧ',
  63716. 'ḩ' => 'Ḩ',
  63717. 'ḫ' => 'Ḫ',
  63718. 'ḭ' => 'Ḭ',
  63719. 'ḯ' => 'Ḯ',
  63720. 'ḱ' => 'Ḱ',
  63721. 'ḳ' => 'Ḳ',
  63722. 'ḵ' => 'Ḵ',
  63723. 'ḷ' => 'Ḷ',
  63724. 'ḹ' => 'Ḹ',
  63725. 'ḻ' => 'Ḻ',
  63726. 'ḽ' => 'Ḽ',
  63727. 'ḿ' => 'Ḿ',
  63728. '�' => 'Ṁ',
  63729. 'ṃ' => 'Ṃ',
  63730. 'ṅ' => 'Ṅ',
  63731. 'ṇ' => 'Ṇ',
  63732. 'ṉ' => 'Ṉ',
  63733. 'ṋ' => 'Ṋ',
  63734. '�' => 'Ṍ',
  63735. '�' => 'Ṏ',
  63736. 'ṑ' => '�',
  63737. 'ṓ' => 'Ṓ',
  63738. 'ṕ' => 'Ṕ',
  63739. 'á¹—' => 'á¹–',
  63740. 'ṙ' => 'Ṙ',
  63741. 'ṛ' => 'Ṛ',
  63742. '�' => 'Ṝ',
  63743. 'ṟ' => 'Ṟ',
  63744. 'ṡ' => 'Ṡ',
  63745. 'á¹£' => 'á¹¢',
  63746. 'ṥ' => 'Ṥ',
  63747. 'ṧ' => 'Ṧ',
  63748. 'ṩ' => 'Ṩ',
  63749. 'ṫ' => 'Ṫ',
  63750. 'ṭ' => 'Ṭ',
  63751. 'ṯ' => 'Ṯ',
  63752. 'á¹±' => 'á¹°',
  63753. 'á¹³' => 'á¹²',
  63754. 'á¹µ' => 'á¹´',
  63755. 'ṷ' => 'Ṷ',
  63756. 'ṹ' => 'Ṹ',
  63757. 'ṻ' => 'Ṻ',
  63758. 'á¹½' => 'á¹¼',
  63759. 'ṿ' => 'Ṿ',
  63760. '�' => 'Ẁ',
  63761. 'ẃ' => 'Ẃ',
  63762. 'ẅ' => 'Ẅ',
  63763. 'ẇ' => 'Ẇ',
  63764. 'ẉ' => 'Ẉ',
  63765. 'ẋ' => 'Ẋ',
  63766. '�' => 'Ẍ',
  63767. '�' => 'Ẏ',
  63768. 'ẑ' => '�',
  63769. 'ẓ' => 'Ẓ',
  63770. 'ẕ' => 'Ẕ',
  63771. 'ẛ' => 'Ṡ',
  63772. 'ạ' => 'Ạ',
  63773. 'ả' => 'Ả',
  63774. 'ấ' => 'Ấ',
  63775. 'ầ' => 'Ầ',
  63776. 'ẩ' => 'Ẩ',
  63777. 'ẫ' => 'Ẫ',
  63778. 'ậ' => 'Ậ',
  63779. 'ắ' => 'Ắ',
  63780. 'ằ' => 'Ằ',
  63781. 'ẳ' => 'Ẳ',
  63782. 'ẵ' => 'Ẵ',
  63783. 'ặ' => 'Ặ',
  63784. 'ẹ' => 'Ẹ',
  63785. 'ẻ' => 'Ẻ',
  63786. 'ẽ' => 'Ẽ',
  63787. 'ế' => 'Ế',
  63788. '�' => 'Ề',
  63789. 'ể' => 'Ể',
  63790. 'ễ' => 'Ễ',
  63791. 'ệ' => 'Ệ',
  63792. 'ỉ' => 'Ỉ',
  63793. 'ị' => 'Ị',
  63794. '�' => 'Ọ',
  63795. '�' => 'Ỏ',
  63796. 'ố' => '�',
  63797. 'ồ' => 'Ồ',
  63798. 'ổ' => 'Ổ',
  63799. 'á»—' => 'á»–',
  63800. 'ộ' => 'Ộ',
  63801. 'ớ' => 'Ớ',
  63802. '�' => 'Ờ',
  63803. 'ở' => 'Ở',
  63804. 'ỡ' => 'Ỡ',
  63805. 'ợ' => 'Ợ',
  63806. 'ụ' => 'Ụ',
  63807. 'ủ' => 'Ủ',
  63808. 'ứ' => 'Ứ',
  63809. 'ừ' => 'Ừ',
  63810. 'ử' => 'Ử',
  63811. 'ữ' => 'Ữ',
  63812. 'á»±' => 'á»°',
  63813. 'ỳ' => 'Ỳ',
  63814. 'ỵ' => 'Ỵ',
  63815. 'ỷ' => 'Ỷ',
  63816. 'ỹ' => 'Ỹ',
  63817. 'ỻ' => 'Ỻ',
  63818. 'ỽ' => 'Ỽ',
  63819. 'ỿ' => 'Ỿ',
  63820. 'ἀ' => 'Ἀ',
  63821. '�' => 'Ἁ',
  63822. 'ἂ' => 'Ἂ',
  63823. 'ἃ' => 'Ἃ',
  63824. 'ἄ' => 'Ἄ',
  63825. 'ἅ' => '�',
  63826. 'ἆ' => 'Ἆ',
  63827. 'ἇ' => '�',
  63828. '�' => 'Ἐ',
  63829. 'ἑ' => 'Ἑ',
  63830. 'ἒ' => 'Ἒ',
  63831. 'ἓ' => 'Ἓ',
  63832. 'ἔ' => 'Ἔ',
  63833. 'ἕ' => '�',
  63834. 'ἠ' => 'Ἠ',
  63835. 'ἡ' => 'Ἡ',
  63836. 'ἢ' => 'Ἢ',
  63837. 'ἣ' => 'Ἣ',
  63838. 'ἤ' => 'Ἤ',
  63839. 'á¼¥' => 'á¼­',
  63840. 'ἦ' => 'Ἦ',
  63841. 'ἧ' => 'Ἧ',
  63842. 'ἰ' => 'Ἰ',
  63843. 'á¼±' => 'á¼¹',
  63844. 'ἲ' => 'Ἲ',
  63845. 'á¼³' => 'á¼»',
  63846. 'á¼´' => 'á¼¼',
  63847. 'á¼µ' => 'á¼½',
  63848. 'ἶ' => 'Ἶ',
  63849. 'ἷ' => 'Ἷ',
  63850. 'ὀ' => 'Ὀ',
  63851. '�' => 'Ὁ',
  63852. 'ὂ' => 'Ὂ',
  63853. 'ὃ' => 'Ὃ',
  63854. 'ὄ' => 'Ὄ',
  63855. 'ὅ' => '�',
  63856. 'ὑ' => 'Ὑ',
  63857. 'ὓ' => 'Ὓ',
  63858. 'ὕ' => '�',
  63859. 'ὗ' => 'Ὗ',
  63860. 'ὠ' => 'Ὠ',
  63861. 'ὡ' => 'Ὡ',
  63862. 'ὢ' => 'Ὢ',
  63863. 'ὣ' => 'Ὣ',
  63864. 'ὤ' => 'Ὤ',
  63865. 'á½¥' => 'á½­',
  63866. 'ὦ' => 'Ὦ',
  63867. 'ὧ' => 'Ὧ',
  63868. 'ὰ' => 'Ὰ',
  63869. 'á½±' => 'á¾»',
  63870. 'ὲ' => 'Ὲ',
  63871. 'έ' => 'Έ',
  63872. 'á½´' => 'á¿Š',
  63873. 'á½µ' => 'á¿‹',
  63874. 'ὶ' => 'Ὶ',
  63875. 'á½·' => 'á¿›',
  63876. 'ὸ' => 'Ὸ',
  63877. 'ό' => 'Ό',
  63878. 'ὺ' => 'Ὺ',
  63879. 'á½»' => 'á¿«',
  63880. 'ὼ' => 'Ὼ',
  63881. 'á½½' => 'á¿»',
  63882. 'ᾀ' => 'ᾈ',
  63883. '�' => 'ᾉ',
  63884. 'ᾂ' => 'ᾊ',
  63885. 'ᾃ' => 'ᾋ',
  63886. 'ᾄ' => 'ᾌ',
  63887. 'ᾅ' => '�',
  63888. 'ᾆ' => 'ᾎ',
  63889. 'ᾇ' => '�',
  63890. '�' => 'ᾘ',
  63891. 'ᾑ' => 'ᾙ',
  63892. 'ᾒ' => 'ᾚ',
  63893. 'ᾓ' => 'ᾛ',
  63894. 'ᾔ' => 'ᾜ',
  63895. 'ᾕ' => '�',
  63896. 'ᾖ' => 'ᾞ',
  63897. 'ᾗ' => 'ᾟ',
  63898. 'ᾠ' => 'ᾨ',
  63899. 'ᾡ' => 'ᾩ',
  63900. 'ᾢ' => 'ᾪ',
  63901. 'ᾣ' => 'ᾫ',
  63902. 'ᾤ' => 'ᾬ',
  63903. 'á¾¥' => 'á¾­',
  63904. 'ᾦ' => 'ᾮ',
  63905. 'ᾧ' => 'ᾯ',
  63906. 'ᾰ' => 'Ᾰ',
  63907. 'á¾±' => 'á¾¹',
  63908. 'á¾³' => 'á¾¼',
  63909. 'ι' => 'Ι',
  63910. 'ῃ' => 'ῌ',
  63911. '�' => 'Ῐ',
  63912. 'á¿‘' => 'á¿™',
  63913. 'ῠ' => 'Ῠ',
  63914. 'á¿¡' => 'á¿©',
  63915. 'ῥ' => 'Ῥ',
  63916. 'ῳ' => 'ῼ',
  63917. 'ⅎ' => 'Ⅎ',
  63918. 'â…°' => 'â… ',
  63919. 'â…±' => 'â…¡',
  63920. 'â…²' => 'â…¢',
  63921. 'â…³' => 'â…£',
  63922. 'â…´' => 'â…¤',
  63923. 'â…µ' => 'â…¥',
  63924. 'â…¶' => 'â…¦',
  63925. 'â…·' => 'â…§',
  63926. 'â…¸' => 'â…¨',
  63927. 'â…¹' => 'â…©',
  63928. 'â…º' => 'â…ª',
  63929. 'â…»' => 'â…«',
  63930. 'â…¼' => 'â…¬',
  63931. 'â…½' => 'â…­',
  63932. 'â…¾' => 'â…®',
  63933. 'â…¿' => 'â…¯',
  63934. 'ↄ' => 'Ↄ',
  63935. '�' => 'Ⓐ',
  63936. 'â“‘' => 'â’·',
  63937. 'â“’' => 'â’¸',
  63938. 'â““' => 'â’¹',
  63939. 'â“”' => 'â’º',
  63940. 'â“•' => 'â’»',
  63941. 'â“–' => 'â’¼',
  63942. 'â“—' => 'â’½',
  63943. 'ⓘ' => 'Ⓘ',
  63944. 'â“™' => 'â’¿',
  63945. 'â“š' => 'â“€',
  63946. 'ⓛ' => '�',
  63947. 'ⓜ' => 'Ⓜ',
  63948. '�' => 'Ⓝ',
  63949. 'â“ž' => 'â“„',
  63950. 'â“Ÿ' => 'â“…',
  63951. 'ⓠ' => 'Ⓠ',
  63952. 'ⓡ' => 'Ⓡ',
  63953. 'ⓢ' => 'Ⓢ',
  63954. 'ⓣ' => 'Ⓣ',
  63955. 'ⓤ' => 'Ⓤ',
  63956. 'â“¥' => 'â“‹',
  63957. 'ⓦ' => 'Ⓦ',
  63958. 'ⓧ' => '�',
  63959. 'ⓨ' => 'Ⓨ',
  63960. 'ⓩ' => '�',
  63961. 'â°°' => 'â°€',
  63962. 'â°±' => 'â°�',
  63963. 'â°²' => 'â°‚',
  63964. 'â°³' => 'â°ƒ',
  63965. 'â°´' => 'â°„',
  63966. 'â°µ' => 'â°…',
  63967. 'â°¶' => 'â°†',
  63968. 'â°·' => 'â°‡',
  63969. 'â°¸' => 'â°ˆ',
  63970. 'â°¹' => 'â°‰',
  63971. 'â°º' => 'â°Š',
  63972. 'â°»' => 'â°‹',
  63973. 'ⰼ' => 'Ⰼ',
  63974. 'â°½' => 'â°�',
  63975. 'â°¾' => 'â°Ž',
  63976. 'â°¿' => 'â°�',
  63977. 'â±€' => 'â°�',
  63978. '�' => 'Ⱁ',
  63979. 'ⱂ' => 'Ⱂ',
  63980. 'ⱃ' => 'Ⱃ',
  63981. 'ⱄ' => 'Ⱄ',
  63982. 'â±…' => 'â°•',
  63983. 'ⱆ' => 'Ⱆ',
  63984. 'ⱇ' => 'Ⱇ',
  63985. 'ⱈ' => 'Ⱈ',
  63986. 'ⱉ' => 'Ⱉ',
  63987. 'ⱊ' => 'Ⱊ',
  63988. 'ⱋ' => 'Ⱋ',
  63989. 'ⱌ' => 'Ⱌ',
  63990. '�' => '�',
  63991. 'ⱎ' => 'Ⱎ',
  63992. '�' => 'Ⱏ',
  63993. '�' => 'Ⱐ',
  63994. 'ⱑ' => 'Ⱑ',
  63995. 'â±’' => 'â°¢',
  63996. 'ⱓ' => 'Ⱓ',
  63997. 'â±”' => 'â°¤',
  63998. 'ⱕ' => 'Ⱕ',
  63999. 'â±–' => 'â°¦',
  64000. 'â±—' => 'â°§',
  64001. 'ⱘ' => 'Ⱘ',
  64002. 'â±™' => 'â°©',
  64003. 'ⱚ' => 'Ⱚ',
  64004. 'â±›' => 'â°«',
  64005. 'ⱜ' => 'Ⱜ',
  64006. '�' => 'Ⱝ',
  64007. 'ⱞ' => 'Ⱞ',
  64008. 'ⱡ' => 'Ⱡ',
  64009. 'ⱥ' => 'Ⱥ',
  64010. 'ⱦ' => 'Ⱦ',
  64011. 'ⱨ' => 'Ⱨ',
  64012. 'ⱪ' => 'Ⱪ',
  64013. 'ⱬ' => 'Ⱬ',
  64014. 'â±³' => 'â±²',
  64015. 'ⱶ' => 'Ⱶ',
  64016. '�' => 'Ⲁ',
  64017. 'ⲃ' => 'Ⲃ',
  64018. 'ⲅ' => 'Ⲅ',
  64019. 'ⲇ' => 'Ⲇ',
  64020. 'ⲉ' => 'Ⲉ',
  64021. 'ⲋ' => 'Ⲋ',
  64022. '�' => 'Ⲍ',
  64023. '�' => 'Ⲏ',
  64024. 'ⲑ' => '�',
  64025. 'ⲓ' => 'Ⲓ',
  64026. 'ⲕ' => 'Ⲕ',
  64027. 'â²—' => 'â²–',
  64028. 'ⲙ' => 'Ⲙ',
  64029. 'ⲛ' => 'Ⲛ',
  64030. '�' => 'Ⲝ',
  64031. 'ⲟ' => 'Ⲟ',
  64032. 'ⲡ' => 'Ⲡ',
  64033. 'â²£' => 'â²¢',
  64034. 'ⲥ' => 'Ⲥ',
  64035. 'ⲧ' => 'Ⲧ',
  64036. 'ⲩ' => 'Ⲩ',
  64037. 'ⲫ' => 'Ⲫ',
  64038. 'ⲭ' => 'Ⲭ',
  64039. 'ⲯ' => 'Ⲯ',
  64040. 'â²±' => 'â²°',
  64041. 'â²³' => 'â²²',
  64042. 'â²µ' => 'â²´',
  64043. 'ⲷ' => 'Ⲷ',
  64044. 'ⲹ' => 'Ⲹ',
  64045. 'ⲻ' => 'Ⲻ',
  64046. 'â²½' => 'â²¼',
  64047. 'ⲿ' => 'Ⲿ',
  64048. '�' => 'Ⳁ',
  64049. 'ⳃ' => 'Ⳃ',
  64050. 'ⳅ' => 'Ⳅ',
  64051. 'ⳇ' => 'Ⳇ',
  64052. 'ⳉ' => 'Ⳉ',
  64053. 'ⳋ' => 'Ⳋ',
  64054. '�' => 'Ⳍ',
  64055. '�' => 'Ⳏ',
  64056. 'ⳑ' => '�',
  64057. 'ⳓ' => 'Ⳓ',
  64058. 'ⳕ' => 'Ⳕ',
  64059. 'â³—' => 'â³–',
  64060. 'ⳙ' => 'Ⳙ',
  64061. 'ⳛ' => 'Ⳛ',
  64062. '�' => 'Ⳝ',
  64063. 'ⳟ' => 'Ⳟ',
  64064. 'ⳡ' => 'Ⳡ',
  64065. 'â³£' => 'â³¢',
  64066. 'ⳬ' => 'Ⳬ',
  64067. 'â³®' => 'â³­',
  64068. 'â³³' => 'â³²',
  64069. 'â´€' => 'á‚ ',
  64070. 'â´�' => 'á‚¡',
  64071. 'â´‚' => 'á‚¢',
  64072. 'â´ƒ' => 'á‚£',
  64073. 'ⴄ' => 'Ⴄ',
  64074. 'â´…' => 'á‚¥',
  64075. 'ⴆ' => 'Ⴆ',
  64076. 'ⴇ' => 'Ⴇ',
  64077. 'ⴈ' => 'Ⴈ',
  64078. 'â´‰' => 'á‚©',
  64079. 'ⴊ' => 'Ⴊ',
  64080. 'â´‹' => 'á‚«',
  64081. 'ⴌ' => 'Ⴌ',
  64082. 'â´�' => 'á‚­',
  64083. 'â´Ž' => 'á‚®',
  64084. '�' => 'Ⴏ',
  64085. 'â´�' => 'á‚°',
  64086. 'ⴑ' => 'Ⴑ',
  64087. 'ⴒ' => 'Ⴒ',
  64088. 'ⴓ' => 'Ⴓ',
  64089. 'â´”' => 'á‚´',
  64090. 'ⴕ' => 'Ⴕ',
  64091. 'ⴖ' => 'Ⴖ',
  64092. 'â´—' => 'á‚·',
  64093. 'ⴘ' => 'Ⴘ',
  64094. 'ⴙ' => 'Ⴙ',
  64095. 'ⴚ' => 'Ⴚ',
  64096. 'â´›' => 'á‚»',
  64097. 'ⴜ' => 'Ⴜ',
  64098. '�' => 'Ⴝ',
  64099. 'ⴞ' => 'Ⴞ',
  64100. 'â´Ÿ' => 'á‚¿',
  64101. 'ⴠ' => 'Ⴠ',
  64102. 'ⴡ' => '�',
  64103. 'ⴢ' => 'Ⴢ',
  64104. 'ⴣ' => 'Ⴣ',
  64105. 'ⴤ' => 'Ⴤ',
  64106. 'ⴥ' => 'Ⴥ',
  64107. 'ⴧ' => 'Ⴧ',
  64108. 'ⴭ' => '�',
  64109. '�' => 'Ꙁ',
  64110. 'ꙃ' => 'Ꙃ',
  64111. 'ꙅ' => 'Ꙅ',
  64112. 'ꙇ' => 'Ꙇ',
  64113. 'ꙉ' => 'Ꙉ',
  64114. 'ꙋ' => 'Ꙋ',
  64115. '�' => 'Ꙍ',
  64116. '�' => 'Ꙏ',
  64117. 'ꙑ' => '�',
  64118. 'ꙓ' => 'Ꙓ',
  64119. 'ꙕ' => 'Ꙕ',
  64120. 'ê™—' => 'ê™–',
  64121. 'ꙙ' => 'Ꙙ',
  64122. 'ꙛ' => 'Ꙛ',
  64123. '�' => 'Ꙝ',
  64124. 'ꙟ' => 'Ꙟ',
  64125. 'ꙡ' => 'Ꙡ',
  64126. 'ꙣ' => 'Ꙣ',
  64127. 'ꙥ' => 'Ꙥ',
  64128. 'ꙧ' => 'Ꙧ',
  64129. 'ꙩ' => 'Ꙩ',
  64130. 'ꙫ' => 'Ꙫ',
  64131. 'ꙭ' => 'Ꙭ',
  64132. '�' => 'Ꚁ',
  64133. 'ꚃ' => 'Ꚃ',
  64134. 'êš…' => 'êš„',
  64135. 'ꚇ' => 'Ꚇ',
  64136. 'ꚉ' => 'Ꚉ',
  64137. 'ꚋ' => 'Ꚋ',
  64138. '�' => 'Ꚍ',
  64139. '�' => 'Ꚏ',
  64140. 'ꚑ' => '�',
  64141. 'êš“' => 'êš’',
  64142. 'êš•' => 'êš”',
  64143. 'êš—' => 'êš–',
  64144. 'ꚙ' => 'Ꚙ',
  64145. 'êš›' => 'êšš',
  64146. 'ꜣ' => 'Ꜣ',
  64147. 'ꜥ' => 'Ꜥ',
  64148. 'ꜧ' => 'Ꜧ',
  64149. 'ꜩ' => 'Ꜩ',
  64150. 'ꜫ' => 'Ꜫ',
  64151. 'ꜭ' => 'Ꜭ',
  64152. 'ꜯ' => 'Ꜯ',
  64153. 'ꜳ' => 'Ꜳ',
  64154. 'ꜵ' => 'Ꜵ',
  64155. 'ꜷ' => 'Ꜷ',
  64156. 'ꜹ' => 'Ꜹ',
  64157. 'ꜻ' => 'Ꜻ',
  64158. 'ꜽ' => 'Ꜽ',
  64159. 'ꜿ' => 'Ꜿ',
  64160. '�' => '�',
  64161. '�' => '�',
  64162. '�' => '�',
  64163. '�' => '�',
  64164. '�' => '�',
  64165. '�' => '�',
  64166. '�' => '�',
  64167. '�' => '�',
  64168. '�' => '�',
  64169. '�' => '�',
  64170. '�' => '�',
  64171. '�' => '�',
  64172. '�' => '�',
  64173. '�' => '�',
  64174. '�' => '�',
  64175. '�' => '�',
  64176. '�' => '�',
  64177. '�' => '�',
  64178. '�' => '�',
  64179. '�' => '�',
  64180. '�' => '�',
  64181. '�' => '�',
  64182. '�' => '�',
  64183. '�' => '�',
  64184. '�' => '�',
  64185. '�' => '�',
  64186. '�' => '�',
  64187. '�' => 'Ꞁ',
  64188. 'ꞃ' => 'Ꞃ',
  64189. 'êž…' => 'êž„',
  64190. 'ꞇ' => 'Ꞇ',
  64191. 'ꞌ' => 'Ꞌ',
  64192. 'ꞑ' => '�',
  64193. 'êž“' => 'êž’',
  64194. 'ꞔ' => 'Ꞔ',
  64195. 'êž—' => 'êž–',
  64196. 'ꞙ' => 'Ꞙ',
  64197. 'êž›' => 'êžš',
  64198. '�' => 'Ꞝ',
  64199. 'ꞟ' => 'Ꞟ',
  64200. 'êž¡' => 'êž ',
  64201. 'ꞣ' => 'Ꞣ',
  64202. 'ꞥ' => 'Ꞥ',
  64203. 'ꞧ' => 'Ꞧ',
  64204. 'ꞩ' => 'Ꞩ',
  64205. 'êžµ' => 'êž´',
  64206. 'ꞷ' => 'Ꞷ',
  64207. 'ꞹ' => 'Ꞹ',
  64208. 'ꞻ' => 'Ꞻ',
  64209. 'êž½' => 'êž¼',
  64210. 'êž¿' => 'êž¾',
  64211. 'ꟃ' => 'Ꟃ',
  64212. 'ꟈ' => 'Ꟈ',
  64213. 'ꟊ' => 'Ꟊ',
  64214. 'ꟶ' => 'Ꟶ',
  64215. 'ê­“' => 'êž³',
  64216. 'ꭰ' => 'Ꭰ',
  64217. 'ꭱ' => 'Ꭱ',
  64218. 'ꭲ' => 'Ꭲ',
  64219. 'ꭳ' => 'Ꭳ',
  64220. 'ꭴ' => 'Ꭴ',
  64221. 'ꭵ' => 'Ꭵ',
  64222. 'ꭶ' => 'Ꭶ',
  64223. 'ꭷ' => 'Ꭷ',
  64224. 'ꭸ' => 'Ꭸ',
  64225. 'ꭹ' => 'Ꭹ',
  64226. 'ꭺ' => 'Ꭺ',
  64227. 'ꭻ' => 'Ꭻ',
  64228. 'ꭼ' => 'Ꭼ',
  64229. 'ꭽ' => 'Ꭽ',
  64230. 'ꭾ' => 'Ꭾ',
  64231. 'ꭿ' => 'Ꭿ',
  64232. 'ꮀ' => 'Ꮀ',
  64233. '�' => 'Ꮁ',
  64234. 'ꮂ' => 'Ꮂ',
  64235. 'ꮃ' => 'Ꮃ',
  64236. 'ꮄ' => 'Ꮄ',
  64237. 'ꮅ' => 'Ꮅ',
  64238. 'ꮆ' => 'Ꮆ',
  64239. 'ꮇ' => 'Ꮇ',
  64240. 'ꮈ' => 'Ꮈ',
  64241. 'ꮉ' => 'Ꮉ',
  64242. 'ꮊ' => 'Ꮊ',
  64243. 'ꮋ' => 'Ꮋ',
  64244. 'ꮌ' => 'Ꮌ',
  64245. '�' => 'Ꮍ',
  64246. 'ꮎ' => 'Ꮎ',
  64247. '�' => 'Ꮏ',
  64248. '�' => '�',
  64249. 'ꮑ' => '�',
  64250. 'ꮒ' => '�',
  64251. 'ꮓ' => '�',
  64252. 'ꮔ' => '�',
  64253. 'ꮕ' => '�',
  64254. 'ꮖ' => '�',
  64255. 'ꮗ' => '�',
  64256. 'ꮘ' => '�',
  64257. 'ꮙ' => '�',
  64258. 'ꮚ' => '�',
  64259. 'ꮛ' => '�',
  64260. 'ꮜ' => '�',
  64261. '�' => '�',
  64262. 'ꮞ' => '�',
  64263. 'ꮟ' => '�',
  64264. 'ꮠ' => '�',
  64265. 'ꮡ' => '�',
  64266. 'ꮢ' => '�',
  64267. 'ꮣ' => '�',
  64268. 'ꮤ' => '�',
  64269. 'ꮥ' => '�',
  64270. 'ꮦ' => '�',
  64271. 'ꮧ' => '�',
  64272. 'ꮨ' => '�',
  64273. 'ꮩ' => '�',
  64274. 'ꮪ' => '�',
  64275. 'ꮫ' => '�',
  64276. 'ꮬ' => '�',
  64277. 'ꮭ' => '�',
  64278. 'ꮮ' => '�',
  64279. 'ꮯ' => '�',
  64280. 'ꮰ' => '�',
  64281. 'ꮱ' => '�',
  64282. 'ꮲ' => '�',
  64283. 'ꮳ' => '�',
  64284. 'ꮴ' => '�',
  64285. 'ꮵ' => '�',
  64286. 'ꮶ' => '�',
  64287. 'ꮷ' => '�',
  64288. 'ꮸ' => '�',
  64289. 'ꮹ' => '�',
  64290. 'ꮺ' => '�',
  64291. 'ꮻ' => '�',
  64292. 'ꮼ' => '�',
  64293. 'ꮽ' => '�',
  64294. 'ꮾ' => '�',
  64295. 'ꮿ' => '�',
  64296. '�' => 'A',
  64297. 'b' => 'B',
  64298. 'c' => 'C',
  64299. 'd' => 'D',
  64300. 'ï½…' => 'ï¼¥',
  64301. 'f' => 'F',
  64302. 'g' => 'G',
  64303. 'h' => 'H',
  64304. 'i' => 'I',
  64305. 'j' => 'J',
  64306. 'k' => 'K',
  64307. 'l' => 'L',
  64308. '�' => 'M',
  64309. 'n' => 'N',
  64310. '�' => 'O',
  64311. '�' => 'P',
  64312. 'q' => 'Q',
  64313. 'ï½’' => 'ï¼²',
  64314. 's' => 'S',
  64315. 'ï½”' => 'ï¼´',
  64316. 'u' => 'U',
  64317. 'v' => 'V',
  64318. 'ï½—' => 'ï¼·',
  64319. 'x' => 'X',
  64320. 'ï½™' => 'ï¼¹',
  64321. 'z' => 'Z',
  64322. '�' => '�',
  64323. '�' => '�',
  64324. '�' => '�',
  64325. '�' => '�',
  64326. '�' => '�',
  64327. '�' => '�',
  64328. '�' => '�',
  64329. '�' => '�',
  64330. '�' => '�',
  64331. '�' => '�',
  64332. '�' => '�',
  64333. '�' => '�',
  64334. '�' => '�',
  64335. '�' => '�',
  64336. '�' => '�',
  64337. '�' => '�',
  64338. '�' => '�',
  64339. '�' => '�',
  64340. '�' => '�',
  64341. '�' => '�',
  64342. '�' => '�',
  64343. '�' => '�',
  64344. '�' => '�',
  64345. '�' => '�',
  64346. '�' => '�',
  64347. '�' => '�',
  64348. '�' => '�',
  64349. '�' => '�',
  64350. '�' => '�',
  64351. '�' => '�',
  64352. '�' => '�',
  64353. '�' => '�',
  64354. '�' => '�',
  64355. '�' => '�',
  64356. '�' => '�',
  64357. '�' => '�',
  64358. '�' => '�',
  64359. '�' => '�',
  64360. '�' => '�',
  64361. '�' => '�',
  64362. '�' => '�',
  64363. '�' => '�',
  64364. '�' => '�',
  64365. '�' => '�',
  64366. '�' => '�',
  64367. '�' => '�',
  64368. '�' => '�',
  64369. '�' => '�',
  64370. '�' => '�',
  64371. '�' => '�',
  64372. '�' => '�',
  64373. '�' => '�',
  64374. '�' => '�',
  64375. '�' => '�',
  64376. '�' => '�',
  64377. '�' => '�',
  64378. '�' => '�',
  64379. '�' => '�',
  64380. '�' => '�',
  64381. '�' => '�',
  64382. '�' => '�',
  64383. '�' => '�',
  64384. '�' => '�',
  64385. '�' => '�',
  64386. '�' => '�',
  64387. '�' => '�',
  64388. '�' => '�',
  64389. '�' => '�',
  64390. '�' => '�',
  64391. '�' => '�',
  64392. '�' => '�',
  64393. '�' => '�',
  64394. '�' => '�',
  64395. '�' => '�',
  64396. '�' => '�',
  64397. '�' => '�',
  64398. '�' => '�',
  64399. '�' => '�',
  64400. '�' => '�',
  64401. '�' => '�',
  64402. '�' => '�',
  64403. '�' => '�',
  64404. '�' => '�',
  64405. '�' => '�',
  64406. '�' => '�',
  64407. '�' => '�',
  64408. '�' => '�',
  64409. '�' => '�',
  64410. '�' => '�',
  64411. '�' => '�',
  64412. '�' => '�',
  64413. '�' => '�',
  64414. '�' => '�',
  64415. '�' => '�',
  64416. '�' => '�',
  64417. '�' => '�',
  64418. '�' => '�',
  64419. '�' => '�',
  64420. '�' => '�',
  64421. '�' => '�',
  64422. '�' => '�',
  64423. '�' => '�',
  64424. '�' => '�',
  64425. '�' => '�',
  64426. '�' => '�',
  64427. '�' => '�',
  64428. '�' => '�',
  64429. '�' => '�',
  64430. '�' => '�',
  64431. '�' => '�',
  64432. '�' => '�',
  64433. '�' => '�',
  64434. '�' => '�',
  64435. '�' => '�',
  64436. '�' => '�',
  64437. '�' => '�',
  64438. '�' => '�',
  64439. '�' => '�',
  64440. '�' => '�',
  64441. '�' => '�',
  64442. '�' => '�',
  64443. '�' => '�',
  64444. '�' => '�',
  64445. '�' => '�',
  64446. '�' => '�',
  64447. '�' => '�',
  64448. '�' => '�',
  64449. 'ð‘£€' => 'ð‘¢ ',
  64450. '�' => '𑢡',
  64451. '𑣂' => '𑢢',
  64452. '𑣃' => '𑢣',
  64453. '𑣄' => '𑢤',
  64454. 'ð‘£…' => 'ð‘¢¥',
  64455. '𑣆' => '𑢦',
  64456. '𑣇' => '𑢧',
  64457. '𑣈' => '𑢨',
  64458. '𑣉' => '𑢩',
  64459. '𑣊' => '𑢪',
  64460. '𑣋' => '𑢫',
  64461. '𑣌' => '𑢬',
  64462. '�' => '𑢭',
  64463. '𑣎' => '𑢮',
  64464. '�' => '𑢯',
  64465. '�' => '𑢰',
  64466. '𑣑' => '𑢱',
  64467. 'ð‘£’' => 'ð‘¢²',
  64468. '𑣓' => '𑢳',
  64469. 'ð‘£”' => 'ð‘¢´',
  64470. '𑣕' => '𑢵',
  64471. '𑣖' => '𑢶',
  64472. 'ð‘£—' => 'ð‘¢·',
  64473. '𑣘' => '𑢸',
  64474. 'ð‘£™' => 'ð‘¢¹',
  64475. '𑣚' => '𑢺',
  64476. 'ð‘£›' => 'ð‘¢»',
  64477. '𑣜' => '𑢼',
  64478. '�' => '𑢽',
  64479. '𑣞' => '𑢾',
  64480. '𑣟' => '𑢿',
  64481. 'ð–¹ ' => 'ð–¹€',
  64482. '𖹡' => '�',
  64483. '𖹢' => '𖹂',
  64484. '𖹣' => '𖹃',
  64485. '𖹤' => '𖹄',
  64486. 'ð–¹¥' => 'ð–¹…',
  64487. '𖹦' => '𖹆',
  64488. '𖹧' => '𖹇',
  64489. '𖹨' => '𖹈',
  64490. '𖹩' => '𖹉',
  64491. '𖹪' => '𖹊',
  64492. '𖹫' => '𖹋',
  64493. '𖹬' => '𖹌',
  64494. '𖹭' => '�',
  64495. '𖹮' => '𖹎',
  64496. '𖹯' => '�',
  64497. '𖹰' => '�',
  64498. '𖹱' => '𖹑',
  64499. 'ð–¹²' => 'ð–¹’',
  64500. '𖹳' => '𖹓',
  64501. 'ð–¹´' => 'ð–¹”',
  64502. '𖹵' => '𖹕',
  64503. '𖹶' => '𖹖',
  64504. 'ð–¹·' => 'ð–¹—',
  64505. '𖹸' => '𖹘',
  64506. 'ð–¹¹' => 'ð–¹™',
  64507. '𖹺' => '𖹚',
  64508. 'ð–¹»' => 'ð–¹›',
  64509. '𖹼' => '𖹜',
  64510. '𖹽' => '�',
  64511. '𖹾' => '𖹞',
  64512. '𖹿' => '𖹟',
  64513. '𞤢' => '𞤀',
  64514. '𞤣' => '�',
  64515. '𞤤' => '𞤂',
  64516. '𞤥' => '𞤃',
  64517. '𞤦' => '𞤄',
  64518. '𞤧' => '𞤅',
  64519. '𞤨' => '𞤆',
  64520. '𞤩' => '𞤇',
  64521. '𞤪' => '𞤈',
  64522. '𞤫' => '𞤉',
  64523. '𞤬' => '𞤊',
  64524. '𞤭' => '𞤋',
  64525. '𞤮' => '𞤌',
  64526. '𞤯' => '�',
  64527. '𞤰' => '𞤎',
  64528. '𞤱' => '�',
  64529. '𞤲' => '�',
  64530. '𞤳' => '𞤑',
  64531. '𞤴' => '𞤒',
  64532. '𞤵' => '𞤓',
  64533. '𞤶' => '𞤔',
  64534. '𞤷' => '𞤕',
  64535. '𞤸' => '𞤖',
  64536. '𞤹' => '𞤗',
  64537. '𞤺' => '𞤘',
  64538. '𞤻' => '𞤙',
  64539. '𞤼' => '𞤚',
  64540. '𞤽' => '𞤛',
  64541. '𞤾' => '𞤜',
  64542. '𞤿' => '�',
  64543. '𞥀' => '𞤞',
  64544. '�' => '𞤟',
  64545. '𞥂' => '𞤠',
  64546. '𞥃' => '𞤡',
  64547. );
  64548. <?php
  64549. use Symfony\Polyfill\Mbstring as p;
  64550. if (!function_exists('mb_convert_encoding')) {
  64551. function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
  64552. }
  64553. if (!function_exists('mb_decode_mimeheader')) {
  64554. function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
  64555. }
  64556. if (!function_exists('mb_encode_mimeheader')) {
  64557. 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); }
  64558. }
  64559. if (!function_exists('mb_decode_numericentity')) {
  64560. function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
  64561. }
  64562. if (!function_exists('mb_encode_numericentity')) {
  64563. function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
  64564. }
  64565. if (!function_exists('mb_convert_case')) {
  64566. function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
  64567. }
  64568. if (!function_exists('mb_internal_encoding')) {
  64569. function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
  64570. }
  64571. if (!function_exists('mb_language')) {
  64572. function mb_language($language = null) { return p\Mbstring::mb_language($language); }
  64573. }
  64574. if (!function_exists('mb_list_encodings')) {
  64575. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  64576. }
  64577. if (!function_exists('mb_encoding_aliases')) {
  64578. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  64579. }
  64580. if (!function_exists('mb_check_encoding')) {
  64581. function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
  64582. }
  64583. if (!function_exists('mb_detect_encoding')) {
  64584. function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
  64585. }
  64586. if (!function_exists('mb_detect_order')) {
  64587. function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
  64588. }
  64589. if (!function_exists('mb_parse_str')) {
  64590. function mb_parse_str($string, &$result = array()) { parse_str($string, $result); }
  64591. }
  64592. if (!function_exists('mb_strlen')) {
  64593. function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
  64594. }
  64595. if (!function_exists('mb_strpos')) {
  64596. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
  64597. }
  64598. if (!function_exists('mb_strtolower')) {
  64599. function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
  64600. }
  64601. if (!function_exists('mb_strtoupper')) {
  64602. function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
  64603. }
  64604. if (!function_exists('mb_substitute_character')) {
  64605. function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
  64606. }
  64607. if (!function_exists('mb_substr')) {
  64608. function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
  64609. }
  64610. if (!function_exists('mb_stripos')) {
  64611. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
  64612. }
  64613. if (!function_exists('mb_stristr')) {
  64614. function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
  64615. }
  64616. if (!function_exists('mb_strrchr')) {
  64617. function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
  64618. }
  64619. if (!function_exists('mb_strrichr')) {
  64620. function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
  64621. }
  64622. if (!function_exists('mb_strripos')) {
  64623. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
  64624. }
  64625. if (!function_exists('mb_strrpos')) {
  64626. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
  64627. }
  64628. if (!function_exists('mb_strstr')) {
  64629. function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
  64630. }
  64631. if (!function_exists('mb_get_info')) {
  64632. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  64633. }
  64634. if (!function_exists('mb_http_output')) {
  64635. function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
  64636. }
  64637. if (!function_exists('mb_strwidth')) {
  64638. function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
  64639. }
  64640. if (!function_exists('mb_substr_count')) {
  64641. function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
  64642. }
  64643. if (!function_exists('mb_output_handler')) {
  64644. function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
  64645. }
  64646. if (!function_exists('mb_http_input')) {
  64647. function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
  64648. }
  64649. if (PHP_VERSION_ID >= 80000) {
  64650. require_once __DIR__.'/Resources/mb_convert_variables.php8';
  64651. } elseif (!function_exists('mb_convert_variables')) {
  64652. 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); }
  64653. }
  64654. if (!function_exists('mb_ord')) {
  64655. function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
  64656. }
  64657. if (!function_exists('mb_chr')) {
  64658. function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
  64659. }
  64660. if (!function_exists('mb_scrub')) {
  64661. function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
  64662. }
  64663. if (!function_exists('mb_str_split')) {
  64664. function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
  64665. }
  64666. if (extension_loaded('mbstring')) {
  64667. return;
  64668. }
  64669. if (!defined('MB_CASE_UPPER')) {
  64670. define('MB_CASE_UPPER', 0);
  64671. }
  64672. if (!defined('MB_CASE_LOWER')) {
  64673. define('MB_CASE_LOWER', 1);
  64674. }
  64675. if (!defined('MB_CASE_TITLE')) {
  64676. define('MB_CASE_TITLE', 2);
  64677. }
  64678. <?php
  64679. namespace Symfony\Component\Process\Exception;
  64680. interface ExceptionInterface
  64681. {
  64682. }
  64683. <?php
  64684. namespace Symfony\Component\Process\Exception;
  64685. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  64686. {
  64687. }
  64688. <?php
  64689. namespace Symfony\Component\Process\Exception;
  64690. class LogicException extends \LogicException implements ExceptionInterface
  64691. {
  64692. }
  64693. <?php
  64694. namespace Symfony\Component\Process\Exception;
  64695. use Symfony\Component\Process\Process;
  64696. class ProcessFailedException extends RuntimeException
  64697. {
  64698. private $process;
  64699. public function __construct(Process $process)
  64700. {
  64701. if ($process->isSuccessful()) {
  64702. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  64703. }
  64704. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  64705. $process->getCommandLine(),
  64706. $process->getExitCode(),
  64707. $process->getExitCodeText(),
  64708. $process->getWorkingDirectory()
  64709. );
  64710. if (!$process->isOutputDisabled()) {
  64711. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  64712. $process->getOutput(),
  64713. $process->getErrorOutput()
  64714. );
  64715. }
  64716. parent::__construct($error);
  64717. $this->process = $process;
  64718. }
  64719. public function getProcess()
  64720. {
  64721. return $this->process;
  64722. }
  64723. }
  64724. <?php
  64725. namespace Symfony\Component\Process\Exception;
  64726. use Symfony\Component\Process\Process;
  64727. class ProcessTimedOutException extends RuntimeException
  64728. {
  64729. const TYPE_GENERAL = 1;
  64730. const TYPE_IDLE = 2;
  64731. private $process;
  64732. private $timeoutType;
  64733. public function __construct(Process $process, $timeoutType)
  64734. {
  64735. $this->process = $process;
  64736. $this->timeoutType = $timeoutType;
  64737. parent::__construct(sprintf(
  64738. 'The process "%s" exceeded the timeout of %s seconds.',
  64739. $process->getCommandLine(),
  64740. $this->getExceededTimeout()
  64741. ));
  64742. }
  64743. public function getProcess()
  64744. {
  64745. return $this->process;
  64746. }
  64747. public function isGeneralTimeout()
  64748. {
  64749. return self::TYPE_GENERAL === $this->timeoutType;
  64750. }
  64751. public function isIdleTimeout()
  64752. {
  64753. return self::TYPE_IDLE === $this->timeoutType;
  64754. }
  64755. public function getExceededTimeout()
  64756. {
  64757. switch ($this->timeoutType) {
  64758. case self::TYPE_GENERAL:
  64759. return $this->process->getTimeout();
  64760. case self::TYPE_IDLE:
  64761. return $this->process->getIdleTimeout();
  64762. default:
  64763. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  64764. }
  64765. }
  64766. }
  64767. <?php
  64768. namespace Symfony\Component\Process\Exception;
  64769. class RuntimeException extends \RuntimeException implements ExceptionInterface
  64770. {
  64771. }
  64772. <?php
  64773. namespace Symfony\Component\Process;
  64774. class ExecutableFinder
  64775. {
  64776. private $suffixes = array('.exe', '.bat', '.cmd', '.com');
  64777. public function setSuffixes(array $suffixes)
  64778. {
  64779. $this->suffixes = $suffixes;
  64780. }
  64781. public function addSuffix($suffix)
  64782. {
  64783. $this->suffixes[] = $suffix;
  64784. }
  64785. public function find($name, $default = null, array $extraDirs = array())
  64786. {
  64787. if (ini_get('open_basedir')) {
  64788. $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
  64789. $dirs = array();
  64790. foreach ($searchPath as $path) {
  64791. if (@is_dir($path)) {
  64792. $dirs[] = $path;
  64793. } else {
  64794. if (basename($path) == $name && @is_executable($path)) {
  64795. return $path;
  64796. }
  64797. }
  64798. }
  64799. } else {
  64800. $dirs = array_merge(
  64801. explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  64802. $extraDirs
  64803. );
  64804. }
  64805. $suffixes = array('');
  64806. if ('\\' === \DIRECTORY_SEPARATOR) {
  64807. $pathExt = getenv('PATHEXT');
  64808. $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  64809. }
  64810. foreach ($suffixes as $suffix) {
  64811. foreach ($dirs as $dir) {
  64812. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  64813. return $file;
  64814. }
  64815. }
  64816. }
  64817. return $default;
  64818. }
  64819. }
  64820. Copyright (c) 2004-2018 Fabien Potencier
  64821. Permission is hereby granted, free of charge, to any person obtaining a copy
  64822. of this software and associated documentation files (the "Software"), to deal
  64823. in the Software without restriction, including without limitation the rights
  64824. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  64825. copies of the Software, and to permit persons to whom the Software is furnished
  64826. to do so, subject to the following conditions:
  64827. The above copyright notice and this permission notice shall be included in all
  64828. copies or substantial portions of the Software.
  64829. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  64830. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  64831. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  64832. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  64833. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  64834. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  64835. THE SOFTWARE.
  64836. <?php
  64837. namespace Symfony\Component\Process;
  64838. class PhpExecutableFinder
  64839. {
  64840. private $executableFinder;
  64841. public function __construct()
  64842. {
  64843. $this->executableFinder = new ExecutableFinder();
  64844. }
  64845. public function find($includeArgs = true)
  64846. {
  64847. $args = $this->findArguments();
  64848. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  64849. if (\defined('HHVM_VERSION')) {
  64850. return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
  64851. }
  64852. if (\defined('PHP_BINARY') && PHP_BINARY && \in_array(\PHP_SAPI, array('cli', 'cli-server', 'phpdbg'), true)) {
  64853. return PHP_BINARY.$args;
  64854. }
  64855. if ($php = getenv('PHP_PATH')) {
  64856. if (!@is_executable($php)) {
  64857. return false;
  64858. }
  64859. return $php;
  64860. }
  64861. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  64862. if (@is_executable($php)) {
  64863. return $php;
  64864. }
  64865. }
  64866. if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
  64867. return $php;
  64868. }
  64869. $dirs = array(PHP_BINDIR);
  64870. if ('\\' === \DIRECTORY_SEPARATOR) {
  64871. $dirs[] = 'C:\xampp\php\\';
  64872. }
  64873. return $this->executableFinder->find('php', false, $dirs);
  64874. }
  64875. public function findArguments()
  64876. {
  64877. $arguments = array();
  64878. if (\defined('HHVM_VERSION')) {
  64879. $arguments[] = '--php';
  64880. } elseif ('phpdbg' === \PHP_SAPI) {
  64881. $arguments[] = '-qrr';
  64882. }
  64883. return $arguments;
  64884. }
  64885. }
  64886. <?php
  64887. namespace Symfony\Component\Process;
  64888. use Symfony\Component\Process\Exception\RuntimeException;
  64889. class PhpProcess extends Process
  64890. {
  64891. public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
  64892. {
  64893. $executableFinder = new PhpExecutableFinder();
  64894. if (false === $php = $executableFinder->find()) {
  64895. $php = null;
  64896. }
  64897. if ('phpdbg' === \PHP_SAPI) {
  64898. $file = tempnam(sys_get_temp_dir(), 'dbg');
  64899. file_put_contents($file, $script);
  64900. register_shutdown_function('unlink', $file);
  64901. $php .= ' '.ProcessUtils::escapeArgument($file);
  64902. $script = null;
  64903. }
  64904. if ('\\' !== \DIRECTORY_SEPARATOR && null !== $php) {
  64905. $php = 'exec '.$php;
  64906. }
  64907. parent::__construct($php, $cwd, $env, $script, $timeout, $options);
  64908. }
  64909. public function setPhpBinary($php)
  64910. {
  64911. $this->setCommandLine($php);
  64912. }
  64913. public function start($callback = null)
  64914. {
  64915. if (null === $this->getCommandLine()) {
  64916. throw new RuntimeException('Unable to find the PHP executable.');
  64917. }
  64918. parent::start($callback);
  64919. }
  64920. }
  64921. <?php
  64922. namespace Symfony\Component\Process\Pipes;
  64923. abstract class AbstractPipes implements PipesInterface
  64924. {
  64925. public $pipes = array();
  64926. private $inputBuffer = '';
  64927. private $input;
  64928. private $blocked = true;
  64929. private $lastError;
  64930. public function __construct($input)
  64931. {
  64932. if (\is_resource($input)) {
  64933. $this->input = $input;
  64934. } elseif (\is_string($input)) {
  64935. $this->inputBuffer = $input;
  64936. } else {
  64937. $this->inputBuffer = (string) $input;
  64938. }
  64939. }
  64940. public function close()
  64941. {
  64942. foreach ($this->pipes as $pipe) {
  64943. fclose($pipe);
  64944. }
  64945. $this->pipes = array();
  64946. }
  64947. protected function hasSystemCallBeenInterrupted()
  64948. {
  64949. $lastError = $this->lastError;
  64950. $this->lastError = null;
  64951. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  64952. }
  64953. protected function unblock()
  64954. {
  64955. if (!$this->blocked) {
  64956. return;
  64957. }
  64958. foreach ($this->pipes as $pipe) {
  64959. stream_set_blocking($pipe, 0);
  64960. }
  64961. if (null !== $this->input) {
  64962. stream_set_blocking($this->input, 0);
  64963. }
  64964. $this->blocked = false;
  64965. }
  64966. protected function write()
  64967. {
  64968. if (!isset($this->pipes[0])) {
  64969. return;
  64970. }
  64971. $input = $this->input;
  64972. $r = $e = array();
  64973. $w = array($this->pipes[0]);
  64974. if (false === @stream_select($r, $w, $e, 0, 0)) {
  64975. return;
  64976. }
  64977. foreach ($w as $stdin) {
  64978. if (isset($this->inputBuffer[0])) {
  64979. $written = fwrite($stdin, $this->inputBuffer);
  64980. $this->inputBuffer = substr($this->inputBuffer, $written);
  64981. if (isset($this->inputBuffer[0])) {
  64982. return array($this->pipes[0]);
  64983. }
  64984. }
  64985. if ($input) {
  64986. for (;;) {
  64987. $data = fread($input, self::CHUNK_SIZE);
  64988. if (!isset($data[0])) {
  64989. break;
  64990. }
  64991. $written = fwrite($stdin, $data);
  64992. $data = substr($data, $written);
  64993. if (isset($data[0])) {
  64994. $this->inputBuffer = $data;
  64995. return array($this->pipes[0]);
  64996. }
  64997. }
  64998. if (feof($input)) {
  64999. $this->input = null;
  65000. }
  65001. }
  65002. }
  65003. if (null === $this->input && !isset($this->inputBuffer[0])) {
  65004. fclose($this->pipes[0]);
  65005. unset($this->pipes[0]);
  65006. } elseif (!$w) {
  65007. return array($this->pipes[0]);
  65008. }
  65009. }
  65010. public function handleError($type, $msg)
  65011. {
  65012. $this->lastError = $msg;
  65013. }
  65014. }
  65015. <?php
  65016. namespace Symfony\Component\Process\Pipes;
  65017. interface PipesInterface
  65018. {
  65019. const CHUNK_SIZE = 16384;
  65020. public function getDescriptors();
  65021. public function getFiles();
  65022. public function readAndWrite($blocking, $close = false);
  65023. public function areOpen();
  65024. public function close();
  65025. }
  65026. <?php
  65027. namespace Symfony\Component\Process\Pipes;
  65028. use Symfony\Component\Process\Process;
  65029. class UnixPipes extends AbstractPipes
  65030. {
  65031. private $ttyMode;
  65032. private $ptyMode;
  65033. private $disableOutput;
  65034. public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
  65035. {
  65036. $this->ttyMode = (bool) $ttyMode;
  65037. $this->ptyMode = (bool) $ptyMode;
  65038. $this->disableOutput = (bool) $disableOutput;
  65039. parent::__construct($input);
  65040. }
  65041. public function __destruct()
  65042. {
  65043. $this->close();
  65044. }
  65045. public function getDescriptors()
  65046. {
  65047. if ($this->disableOutput) {
  65048. $nullstream = fopen('/dev/null', 'c');
  65049. return array(
  65050. array('pipe', 'r'),
  65051. $nullstream,
  65052. $nullstream,
  65053. );
  65054. }
  65055. if ($this->ttyMode) {
  65056. return array(
  65057. array('file', '/dev/tty', 'r'),
  65058. array('file', '/dev/tty', 'w'),
  65059. array('file', '/dev/tty', 'w'),
  65060. );
  65061. }
  65062. if ($this->ptyMode && Process::isPtySupported()) {
  65063. return array(
  65064. array('pty'),
  65065. array('pty'),
  65066. array('pty'),
  65067. );
  65068. }
  65069. return array(
  65070. array('pipe', 'r'),
  65071. array('pipe', 'w'),
  65072. array('pipe', 'w'),
  65073. );
  65074. }
  65075. public function getFiles()
  65076. {
  65077. return array();
  65078. }
  65079. public function readAndWrite($blocking, $close = false)
  65080. {
  65081. $this->unblock();
  65082. $w = $this->write();
  65083. $read = $e = array();
  65084. $r = $this->pipes;
  65085. unset($r[0]);
  65086. set_error_handler(array($this, 'handleError'));
  65087. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  65088. restore_error_handler();
  65089. if (!$this->hasSystemCallBeenInterrupted()) {
  65090. $this->pipes = array();
  65091. }
  65092. return $read;
  65093. }
  65094. restore_error_handler();
  65095. foreach ($r as $pipe) {
  65096. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  65097. do {
  65098. $data = fread($pipe, self::CHUNK_SIZE);
  65099. $read[$type] .= $data;
  65100. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  65101. if (!isset($read[$type][0])) {
  65102. unset($read[$type]);
  65103. }
  65104. if ($close && feof($pipe)) {
  65105. fclose($pipe);
  65106. unset($this->pipes[$type]);
  65107. }
  65108. }
  65109. return $read;
  65110. }
  65111. public function areOpen()
  65112. {
  65113. return (bool) $this->pipes;
  65114. }
  65115. public static function create(Process $process, $input)
  65116. {
  65117. return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
  65118. }
  65119. }
  65120. <?php
  65121. namespace Symfony\Component\Process\Pipes;
  65122. use Symfony\Component\Process\Exception\RuntimeException;
  65123. use Symfony\Component\Process\Process;
  65124. class WindowsPipes extends AbstractPipes
  65125. {
  65126. private $files = array();
  65127. private $fileHandles = array();
  65128. private $lockHandles = array();
  65129. private $readBytes = array(
  65130. Process::STDOUT => 0,
  65131. Process::STDERR => 0,
  65132. );
  65133. private $disableOutput;
  65134. public function __construct($disableOutput, $input)
  65135. {
  65136. $this->disableOutput = (bool) $disableOutput;
  65137. if (!$this->disableOutput) {
  65138. $pipes = array(
  65139. Process::STDOUT => Process::OUT,
  65140. Process::STDERR => Process::ERR,
  65141. );
  65142. $tmpDir = sys_get_temp_dir();
  65143. $lastError = 'unknown reason';
  65144. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  65145. for ($i = 0;; ++$i) {
  65146. foreach ($pipes as $pipe => $name) {
  65147. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  65148. if (!$h = fopen($file.'.lock', 'w')) {
  65149. restore_error_handler();
  65150. throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
  65151. }
  65152. if (!flock($h, LOCK_EX | LOCK_NB)) {
  65153. continue 2;
  65154. }
  65155. if (isset($this->lockHandles[$pipe])) {
  65156. flock($this->lockHandles[$pipe], LOCK_UN);
  65157. fclose($this->lockHandles[$pipe]);
  65158. }
  65159. $this->lockHandles[$pipe] = $h;
  65160. if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
  65161. flock($this->lockHandles[$pipe], LOCK_UN);
  65162. fclose($this->lockHandles[$pipe]);
  65163. unset($this->lockHandles[$pipe]);
  65164. continue 2;
  65165. }
  65166. $this->fileHandles[$pipe] = $h;
  65167. $this->files[$pipe] = $file;
  65168. }
  65169. break;
  65170. }
  65171. restore_error_handler();
  65172. }
  65173. parent::__construct($input);
  65174. }
  65175. public function __destruct()
  65176. {
  65177. $this->close();
  65178. }
  65179. public function getDescriptors()
  65180. {
  65181. if ($this->disableOutput) {
  65182. $nullstream = fopen('NUL', 'c');
  65183. return array(
  65184. array('pipe', 'r'),
  65185. $nullstream,
  65186. $nullstream,
  65187. );
  65188. }
  65189. return array(
  65190. array('pipe', 'r'),
  65191. array('file', 'NUL', 'w'),
  65192. array('file', 'NUL', 'w'),
  65193. );
  65194. }
  65195. public function getFiles()
  65196. {
  65197. return $this->files;
  65198. }
  65199. public function readAndWrite($blocking, $close = false)
  65200. {
  65201. $this->unblock();
  65202. $w = $this->write();
  65203. $read = $r = $e = array();
  65204. if ($blocking) {
  65205. if ($w) {
  65206. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  65207. } elseif ($this->fileHandles) {
  65208. usleep(Process::TIMEOUT_PRECISION * 1E6);
  65209. }
  65210. }
  65211. foreach ($this->fileHandles as $type => $fileHandle) {
  65212. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  65213. if (isset($data[0])) {
  65214. $this->readBytes[$type] += \strlen($data);
  65215. $read[$type] = $data;
  65216. }
  65217. if ($close) {
  65218. ftruncate($fileHandle, 0);
  65219. fclose($fileHandle);
  65220. flock($this->lockHandles[$type], LOCK_UN);
  65221. fclose($this->lockHandles[$type]);
  65222. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  65223. }
  65224. }
  65225. return $read;
  65226. }
  65227. public function areOpen()
  65228. {
  65229. return $this->pipes && $this->fileHandles;
  65230. }
  65231. public function close()
  65232. {
  65233. parent::close();
  65234. foreach ($this->fileHandles as $type => $handle) {
  65235. ftruncate($handle, 0);
  65236. fclose($handle);
  65237. flock($this->lockHandles[$type], LOCK_UN);
  65238. fclose($this->lockHandles[$type]);
  65239. }
  65240. $this->fileHandles = $this->lockHandles = array();
  65241. }
  65242. public static function create(Process $process, $input)
  65243. {
  65244. return new static($process->isOutputDisabled(), $input);
  65245. }
  65246. }
  65247. <?php
  65248. namespace Symfony\Component\Process;
  65249. use Symfony\Component\Process\Exception\InvalidArgumentException;
  65250. use Symfony\Component\Process\Exception\LogicException;
  65251. use Symfony\Component\Process\Exception\ProcessFailedException;
  65252. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  65253. use Symfony\Component\Process\Exception\RuntimeException;
  65254. use Symfony\Component\Process\Pipes\PipesInterface;
  65255. use Symfony\Component\Process\Pipes\UnixPipes;
  65256. use Symfony\Component\Process\Pipes\WindowsPipes;
  65257. class Process
  65258. {
  65259. const ERR = 'err';
  65260. const OUT = 'out';
  65261. const STATUS_READY = 'ready';
  65262. const STATUS_STARTED = 'started';
  65263. const STATUS_TERMINATED = 'terminated';
  65264. const STDIN = 0;
  65265. const STDOUT = 1;
  65266. const STDERR = 2;
  65267. const TIMEOUT_PRECISION = 0.2;
  65268. private $callback;
  65269. private $commandline;
  65270. private $cwd;
  65271. private $env;
  65272. private $input;
  65273. private $starttime;
  65274. private $lastOutputTime;
  65275. private $timeout;
  65276. private $idleTimeout;
  65277. private $options;
  65278. private $exitcode;
  65279. private $fallbackStatus = array();
  65280. private $processInformation;
  65281. private $outputDisabled = false;
  65282. private $stdout;
  65283. private $stderr;
  65284. private $enhanceWindowsCompatibility = true;
  65285. private $enhanceSigchildCompatibility;
  65286. private $process;
  65287. private $status = self::STATUS_READY;
  65288. private $incrementalOutputOffset = 0;
  65289. private $incrementalErrorOutputOffset = 0;
  65290. private $tty;
  65291. private $pty;
  65292. private $useFileHandles = false;
  65293. private $processPipes;
  65294. private $latestSignal;
  65295. private static $sigchild;
  65296. public static $exitCodes = array(
  65297. 0 => 'OK',
  65298. 1 => 'General error',
  65299. 2 => 'Misuse of shell builtins',
  65300. 126 => 'Invoked command cannot execute',
  65301. 127 => 'Command not found',
  65302. 128 => 'Invalid exit argument',
  65303. 129 => 'Hangup',
  65304. 130 => 'Interrupt',
  65305. 131 => 'Quit and dump core',
  65306. 132 => 'Illegal instruction',
  65307. 133 => 'Trace/breakpoint trap',
  65308. 134 => 'Process aborted',
  65309. 135 => 'Bus error: "access to undefined portion of memory object"',
  65310. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  65311. 137 => 'Kill (terminate immediately)',
  65312. 138 => 'User-defined 1',
  65313. 139 => 'Segmentation violation',
  65314. 140 => 'User-defined 2',
  65315. 141 => 'Write to pipe with no one reading',
  65316. 142 => 'Signal raised by alarm',
  65317. 143 => 'Termination (request to terminate)',
  65318. 145 => 'Child process terminated, stopped (or continued*)',
  65319. 146 => 'Continue if stopped',
  65320. 147 => 'Stop executing temporarily',
  65321. 148 => 'Terminal stop signal',
  65322. 149 => 'Background process attempting to read from tty ("in")',
  65323. 150 => 'Background process attempting to write to tty ("out")',
  65324. 151 => 'Urgent data available on socket',
  65325. 152 => 'CPU time limit exceeded',
  65326. 153 => 'File size limit exceeded',
  65327. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  65328. 155 => 'Profiling timer expired',
  65329. 157 => 'Pollable event',
  65330. 159 => 'Bad syscall',
  65331. );
  65332. public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
  65333. {
  65334. if (!\function_exists('proc_open')) {
  65335. throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
  65336. }
  65337. $this->commandline = $commandline;
  65338. $this->cwd = $cwd;
  65339. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  65340. $this->cwd = getcwd();
  65341. }
  65342. if (null !== $env) {
  65343. $this->setEnv($env);
  65344. }
  65345. $this->setInput($input);
  65346. $this->setTimeout($timeout);
  65347. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  65348. $this->pty = false;
  65349. $this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
  65350. $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
  65351. }
  65352. public function __destruct()
  65353. {
  65354. $this->stop(0);
  65355. }
  65356. public function __clone()
  65357. {
  65358. $this->resetProcessData();
  65359. }
  65360. public function run($callback = null)
  65361. {
  65362. $this->start($callback);
  65363. return $this->wait();
  65364. }
  65365. public function mustRun($callback = null)
  65366. {
  65367. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  65368. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  65369. }
  65370. if (0 !== $this->run($callback)) {
  65371. throw new ProcessFailedException($this);
  65372. }
  65373. return $this;
  65374. }
  65375. public function start($callback = null)
  65376. {
  65377. if ($this->isRunning()) {
  65378. throw new RuntimeException('Process is already running');
  65379. }
  65380. if ($this->outputDisabled && null !== $callback) {
  65381. throw new LogicException('Output has been disabled, enable it to allow the use of a callback.');
  65382. }
  65383. $this->resetProcessData();
  65384. $this->starttime = $this->lastOutputTime = microtime(true);
  65385. $this->callback = $this->buildCallback($callback);
  65386. $descriptors = $this->getDescriptors();
  65387. $commandline = $this->commandline;
  65388. if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
  65389. $commandline = 'cmd /V:ON /E:ON /D /C "('.$commandline.')';
  65390. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  65391. $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename);
  65392. }
  65393. $commandline .= '"';
  65394. if (!isset($this->options['bypass_shell'])) {
  65395. $this->options['bypass_shell'] = true;
  65396. }
  65397. } elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  65398. $descriptors[3] = array('pipe', 'w');
  65399. $commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  65400. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  65401. $ptsWorkaround = fopen(__FILE__, 'r');
  65402. }
  65403. $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
  65404. if (!\is_resource($this->process)) {
  65405. throw new RuntimeException('Unable to launch a new process.');
  65406. }
  65407. $this->status = self::STATUS_STARTED;
  65408. if (isset($descriptors[3])) {
  65409. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  65410. }
  65411. if ($this->tty) {
  65412. return;
  65413. }
  65414. $this->updateStatus(false);
  65415. $this->checkTimeout();
  65416. }
  65417. public function restart($callback = null)
  65418. {
  65419. if ($this->isRunning()) {
  65420. throw new RuntimeException('Process is already running');
  65421. }
  65422. $process = clone $this;
  65423. $process->start($callback);
  65424. return $process;
  65425. }
  65426. public function wait($callback = null)
  65427. {
  65428. $this->requireProcessIsStarted(__FUNCTION__);
  65429. $this->updateStatus(false);
  65430. if (null !== $callback) {
  65431. $this->callback = $this->buildCallback($callback);
  65432. }
  65433. do {
  65434. $this->checkTimeout();
  65435. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  65436. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  65437. } while ($running);
  65438. while ($this->isRunning()) {
  65439. usleep(1000);
  65440. }
  65441. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  65442. throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
  65443. }
  65444. return $this->exitcode;
  65445. }
  65446. public function getPid()
  65447. {
  65448. return $this->isRunning() ? $this->processInformation['pid'] : null;
  65449. }
  65450. public function signal($signal)
  65451. {
  65452. $this->doSignal($signal, true);
  65453. return $this;
  65454. }
  65455. public function disableOutput()
  65456. {
  65457. if ($this->isRunning()) {
  65458. throw new RuntimeException('Disabling output while the process is running is not possible.');
  65459. }
  65460. if (null !== $this->idleTimeout) {
  65461. throw new LogicException('Output can not be disabled while an idle timeout is set.');
  65462. }
  65463. $this->outputDisabled = true;
  65464. return $this;
  65465. }
  65466. public function enableOutput()
  65467. {
  65468. if ($this->isRunning()) {
  65469. throw new RuntimeException('Enabling output while the process is running is not possible.');
  65470. }
  65471. $this->outputDisabled = false;
  65472. return $this;
  65473. }
  65474. public function isOutputDisabled()
  65475. {
  65476. return $this->outputDisabled;
  65477. }
  65478. public function getOutput()
  65479. {
  65480. $this->readPipesForOutput(__FUNCTION__);
  65481. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  65482. return '';
  65483. }
  65484. return $ret;
  65485. }
  65486. public function getIncrementalOutput()
  65487. {
  65488. $this->readPipesForOutput(__FUNCTION__);
  65489. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  65490. $this->incrementalOutputOffset = ftell($this->stdout);
  65491. if (false === $latest) {
  65492. return '';
  65493. }
  65494. return $latest;
  65495. }
  65496. public function clearOutput()
  65497. {
  65498. ftruncate($this->stdout, 0);
  65499. fseek($this->stdout, 0);
  65500. $this->incrementalOutputOffset = 0;
  65501. return $this;
  65502. }
  65503. public function getErrorOutput()
  65504. {
  65505. $this->readPipesForOutput(__FUNCTION__);
  65506. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  65507. return '';
  65508. }
  65509. return $ret;
  65510. }
  65511. public function getIncrementalErrorOutput()
  65512. {
  65513. $this->readPipesForOutput(__FUNCTION__);
  65514. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  65515. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  65516. if (false === $latest) {
  65517. return '';
  65518. }
  65519. return $latest;
  65520. }
  65521. public function clearErrorOutput()
  65522. {
  65523. ftruncate($this->stderr, 0);
  65524. fseek($this->stderr, 0);
  65525. $this->incrementalErrorOutputOffset = 0;
  65526. return $this;
  65527. }
  65528. public function getExitCode()
  65529. {
  65530. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  65531. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  65532. }
  65533. $this->updateStatus(false);
  65534. return $this->exitcode;
  65535. }
  65536. public function getExitCodeText()
  65537. {
  65538. if (null === $exitcode = $this->getExitCode()) {
  65539. return;
  65540. }
  65541. return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
  65542. }
  65543. public function isSuccessful()
  65544. {
  65545. return 0 === $this->getExitCode();
  65546. }
  65547. public function hasBeenSignaled()
  65548. {
  65549. $this->requireProcessIsTerminated(__FUNCTION__);
  65550. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  65551. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  65552. }
  65553. return $this->processInformation['signaled'];
  65554. }
  65555. public function getTermSignal()
  65556. {
  65557. $this->requireProcessIsTerminated(__FUNCTION__);
  65558. if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
  65559. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  65560. }
  65561. return $this->processInformation['termsig'];
  65562. }
  65563. public function hasBeenStopped()
  65564. {
  65565. $this->requireProcessIsTerminated(__FUNCTION__);
  65566. return $this->processInformation['stopped'];
  65567. }
  65568. public function getStopSignal()
  65569. {
  65570. $this->requireProcessIsTerminated(__FUNCTION__);
  65571. return $this->processInformation['stopsig'];
  65572. }
  65573. public function isRunning()
  65574. {
  65575. if (self::STATUS_STARTED !== $this->status) {
  65576. return false;
  65577. }
  65578. $this->updateStatus(false);
  65579. return $this->processInformation['running'];
  65580. }
  65581. public function isStarted()
  65582. {
  65583. return self::STATUS_READY != $this->status;
  65584. }
  65585. public function isTerminated()
  65586. {
  65587. $this->updateStatus(false);
  65588. return self::STATUS_TERMINATED == $this->status;
  65589. }
  65590. public function getStatus()
  65591. {
  65592. $this->updateStatus(false);
  65593. return $this->status;
  65594. }
  65595. public function stop($timeout = 10, $signal = null)
  65596. {
  65597. $timeoutMicro = microtime(true) + $timeout;
  65598. if ($this->isRunning()) {
  65599. $this->doSignal(15, false);
  65600. do {
  65601. usleep(1000);
  65602. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  65603. if ($this->isRunning()) {
  65604. $this->doSignal($signal ?: 9, false);
  65605. }
  65606. }
  65607. if ($this->isRunning()) {
  65608. if (isset($this->fallbackStatus['pid'])) {
  65609. unset($this->fallbackStatus['pid']);
  65610. return $this->stop(0, $signal);
  65611. }
  65612. $this->close();
  65613. }
  65614. return $this->exitcode;
  65615. }
  65616. public function addOutput($line)
  65617. {
  65618. $this->lastOutputTime = microtime(true);
  65619. fseek($this->stdout, 0, SEEK_END);
  65620. fwrite($this->stdout, $line);
  65621. fseek($this->stdout, $this->incrementalOutputOffset);
  65622. }
  65623. public function addErrorOutput($line)
  65624. {
  65625. $this->lastOutputTime = microtime(true);
  65626. fseek($this->stderr, 0, SEEK_END);
  65627. fwrite($this->stderr, $line);
  65628. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  65629. }
  65630. public function getCommandLine()
  65631. {
  65632. return $this->commandline;
  65633. }
  65634. public function setCommandLine($commandline)
  65635. {
  65636. $this->commandline = $commandline;
  65637. return $this;
  65638. }
  65639. public function getTimeout()
  65640. {
  65641. return $this->timeout;
  65642. }
  65643. public function getIdleTimeout()
  65644. {
  65645. return $this->idleTimeout;
  65646. }
  65647. public function setTimeout($timeout)
  65648. {
  65649. $this->timeout = $this->validateTimeout($timeout);
  65650. return $this;
  65651. }
  65652. public function setIdleTimeout($timeout)
  65653. {
  65654. if (null !== $timeout && $this->outputDisabled) {
  65655. throw new LogicException('Idle timeout can not be set while the output is disabled.');
  65656. }
  65657. $this->idleTimeout = $this->validateTimeout($timeout);
  65658. return $this;
  65659. }
  65660. public function setTty($tty)
  65661. {
  65662. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  65663. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  65664. }
  65665. if ($tty) {
  65666. static $isTtySupported;
  65667. if (null === $isTtySupported) {
  65668. $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);
  65669. }
  65670. if (!$isTtySupported) {
  65671. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  65672. }
  65673. }
  65674. $this->tty = (bool) $tty;
  65675. return $this;
  65676. }
  65677. public function isTty()
  65678. {
  65679. return $this->tty;
  65680. }
  65681. public function setPty($bool)
  65682. {
  65683. $this->pty = (bool) $bool;
  65684. return $this;
  65685. }
  65686. public function isPty()
  65687. {
  65688. return $this->pty;
  65689. }
  65690. public function getWorkingDirectory()
  65691. {
  65692. if (null === $this->cwd) {
  65693. return getcwd() ?: null;
  65694. }
  65695. return $this->cwd;
  65696. }
  65697. public function setWorkingDirectory($cwd)
  65698. {
  65699. $this->cwd = $cwd;
  65700. return $this;
  65701. }
  65702. public function getEnv()
  65703. {
  65704. return $this->env;
  65705. }
  65706. public function setEnv(array $env)
  65707. {
  65708. $env = array_filter($env, function ($value) {
  65709. return !\is_array($value);
  65710. });
  65711. $this->env = array();
  65712. foreach ($env as $key => $value) {
  65713. $this->env[$key] = (string) $value;
  65714. }
  65715. return $this;
  65716. }
  65717. public function getStdin()
  65718. {
  65719. @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);
  65720. return $this->getInput();
  65721. }
  65722. public function getInput()
  65723. {
  65724. return $this->input;
  65725. }
  65726. public function setStdin($stdin)
  65727. {
  65728. @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);
  65729. return $this->setInput($stdin);
  65730. }
  65731. public function setInput($input)
  65732. {
  65733. if ($this->isRunning()) {
  65734. throw new LogicException('Input can not be set while the process is running.');
  65735. }
  65736. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  65737. return $this;
  65738. }
  65739. public function getOptions()
  65740. {
  65741. return $this->options;
  65742. }
  65743. public function setOptions(array $options)
  65744. {
  65745. $this->options = $options;
  65746. return $this;
  65747. }
  65748. public function getEnhanceWindowsCompatibility()
  65749. {
  65750. return $this->enhanceWindowsCompatibility;
  65751. }
  65752. public function setEnhanceWindowsCompatibility($enhance)
  65753. {
  65754. $this->enhanceWindowsCompatibility = (bool) $enhance;
  65755. return $this;
  65756. }
  65757. public function getEnhanceSigchildCompatibility()
  65758. {
  65759. return $this->enhanceSigchildCompatibility;
  65760. }
  65761. public function setEnhanceSigchildCompatibility($enhance)
  65762. {
  65763. $this->enhanceSigchildCompatibility = (bool) $enhance;
  65764. return $this;
  65765. }
  65766. public function checkTimeout()
  65767. {
  65768. if (self::STATUS_STARTED !== $this->status) {
  65769. return;
  65770. }
  65771. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  65772. $this->stop(0);
  65773. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  65774. }
  65775. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  65776. $this->stop(0);
  65777. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  65778. }
  65779. }
  65780. public static function isPtySupported()
  65781. {
  65782. static $result;
  65783. if (null !== $result) {
  65784. return $result;
  65785. }
  65786. if ('\\' === \DIRECTORY_SEPARATOR) {
  65787. return $result = false;
  65788. }
  65789. return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);
  65790. }
  65791. private function getDescriptors()
  65792. {
  65793. if ('\\' === \DIRECTORY_SEPARATOR) {
  65794. $this->processPipes = WindowsPipes::create($this, $this->input);
  65795. } else {
  65796. $this->processPipes = UnixPipes::create($this, $this->input);
  65797. }
  65798. return $this->processPipes->getDescriptors();
  65799. }
  65800. protected function buildCallback($callback)
  65801. {
  65802. $that = $this;
  65803. $out = self::OUT;
  65804. $callback = function ($type, $data) use ($that, $callback, $out) {
  65805. if ($out == $type) {
  65806. $that->addOutput($data);
  65807. } else {
  65808. $that->addErrorOutput($data);
  65809. }
  65810. if (null !== $callback) {
  65811. \call_user_func($callback, $type, $data);
  65812. }
  65813. };
  65814. return $callback;
  65815. }
  65816. protected function updateStatus($blocking)
  65817. {
  65818. if (self::STATUS_STARTED !== $this->status) {
  65819. return;
  65820. }
  65821. $this->processInformation = proc_get_status($this->process);
  65822. $running = $this->processInformation['running'];
  65823. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  65824. if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  65825. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  65826. }
  65827. if (!$running) {
  65828. $this->close();
  65829. }
  65830. }
  65831. protected function isSigchildEnabled()
  65832. {
  65833. if (null !== self::$sigchild) {
  65834. return self::$sigchild;
  65835. }
  65836. if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
  65837. return self::$sigchild = false;
  65838. }
  65839. ob_start();
  65840. phpinfo(INFO_GENERAL);
  65841. return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
  65842. }
  65843. private function readPipesForOutput($caller)
  65844. {
  65845. if ($this->outputDisabled) {
  65846. throw new LogicException('Output has been disabled.');
  65847. }
  65848. $this->requireProcessIsStarted($caller);
  65849. $this->updateStatus(false);
  65850. }
  65851. private function validateTimeout($timeout)
  65852. {
  65853. $timeout = (float) $timeout;
  65854. if (0.0 === $timeout) {
  65855. $timeout = null;
  65856. } elseif ($timeout < 0) {
  65857. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  65858. }
  65859. return $timeout;
  65860. }
  65861. private function readPipes($blocking, $close)
  65862. {
  65863. $result = $this->processPipes->readAndWrite($blocking, $close);
  65864. $callback = $this->callback;
  65865. foreach ($result as $type => $data) {
  65866. if (3 !== $type) {
  65867. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  65868. } elseif (!isset($this->fallbackStatus['signaled'])) {
  65869. $this->fallbackStatus['exitcode'] = (int) $data;
  65870. }
  65871. }
  65872. }
  65873. private function close()
  65874. {
  65875. $this->processPipes->close();
  65876. if (\is_resource($this->process)) {
  65877. proc_close($this->process);
  65878. }
  65879. $this->exitcode = $this->processInformation['exitcode'];
  65880. $this->status = self::STATUS_TERMINATED;
  65881. if (-1 === $this->exitcode) {
  65882. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  65883. $this->exitcode = 128 + $this->processInformation['termsig'];
  65884. } elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  65885. $this->processInformation['signaled'] = true;
  65886. $this->processInformation['termsig'] = -1;
  65887. }
  65888. }
  65889. $this->callback = null;
  65890. return $this->exitcode;
  65891. }
  65892. private function resetProcessData()
  65893. {
  65894. $this->starttime = null;
  65895. $this->callback = null;
  65896. $this->exitcode = null;
  65897. $this->fallbackStatus = array();
  65898. $this->processInformation = null;
  65899. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  65900. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  65901. $this->process = null;
  65902. $this->latestSignal = null;
  65903. $this->status = self::STATUS_READY;
  65904. $this->incrementalOutputOffset = 0;
  65905. $this->incrementalErrorOutputOffset = 0;
  65906. }
  65907. private function doSignal($signal, $throwException)
  65908. {
  65909. if (null === $pid = $this->getPid()) {
  65910. if ($throwException) {
  65911. throw new LogicException('Can not send signal on a non running process.');
  65912. }
  65913. return false;
  65914. }
  65915. if ('\\' === \DIRECTORY_SEPARATOR) {
  65916. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  65917. if ($exitCode && $this->isRunning()) {
  65918. if ($throwException) {
  65919. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  65920. }
  65921. return false;
  65922. }
  65923. } else {
  65924. if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
  65925. $ok = @proc_terminate($this->process, $signal);
  65926. } elseif (\function_exists('posix_kill')) {
  65927. $ok = @posix_kill($pid, $signal);
  65928. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  65929. $ok = false === fgets($pipes[2]);
  65930. }
  65931. if (!$ok) {
  65932. if ($throwException) {
  65933. throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
  65934. }
  65935. return false;
  65936. }
  65937. }
  65938. $this->latestSignal = (int) $signal;
  65939. $this->fallbackStatus['signaled'] = true;
  65940. $this->fallbackStatus['exitcode'] = -1;
  65941. $this->fallbackStatus['termsig'] = $this->latestSignal;
  65942. return true;
  65943. }
  65944. private function requireProcessIsStarted($functionName)
  65945. {
  65946. if (!$this->isStarted()) {
  65947. throw new LogicException(sprintf('Process must be started before calling %s.', $functionName));
  65948. }
  65949. }
  65950. private function requireProcessIsTerminated($functionName)
  65951. {
  65952. if (!$this->isTerminated()) {
  65953. throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName));
  65954. }
  65955. }
  65956. }
  65957. <?php
  65958. namespace Symfony\Component\Process;
  65959. use Symfony\Component\Process\Exception\InvalidArgumentException;
  65960. use Symfony\Component\Process\Exception\LogicException;
  65961. class ProcessBuilder
  65962. {
  65963. private $arguments;
  65964. private $cwd;
  65965. private $env = array();
  65966. private $input;
  65967. private $timeout = 60;
  65968. private $options = array();
  65969. private $inheritEnv = true;
  65970. private $prefix = array();
  65971. private $outputDisabled = false;
  65972. public function __construct(array $arguments = array())
  65973. {
  65974. $this->arguments = $arguments;
  65975. }
  65976. public static function create(array $arguments = array())
  65977. {
  65978. return new static($arguments);
  65979. }
  65980. public function add($argument)
  65981. {
  65982. $this->arguments[] = $argument;
  65983. return $this;
  65984. }
  65985. public function setPrefix($prefix)
  65986. {
  65987. $this->prefix = \is_array($prefix) ? $prefix : array($prefix);
  65988. return $this;
  65989. }
  65990. public function setArguments(array $arguments)
  65991. {
  65992. $this->arguments = $arguments;
  65993. return $this;
  65994. }
  65995. public function setWorkingDirectory($cwd)
  65996. {
  65997. $this->cwd = $cwd;
  65998. return $this;
  65999. }
  66000. public function inheritEnvironmentVariables($inheritEnv = true)
  66001. {
  66002. $this->inheritEnv = $inheritEnv;
  66003. return $this;
  66004. }
  66005. public function setEnv($name, $value)
  66006. {
  66007. $this->env[$name] = $value;
  66008. return $this;
  66009. }
  66010. public function addEnvironmentVariables(array $variables)
  66011. {
  66012. $this->env = array_replace($this->env, $variables);
  66013. return $this;
  66014. }
  66015. public function setInput($input)
  66016. {
  66017. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  66018. return $this;
  66019. }
  66020. public function setTimeout($timeout)
  66021. {
  66022. if (null === $timeout) {
  66023. $this->timeout = null;
  66024. return $this;
  66025. }
  66026. $timeout = (float) $timeout;
  66027. if ($timeout < 0) {
  66028. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  66029. }
  66030. $this->timeout = $timeout;
  66031. return $this;
  66032. }
  66033. public function setOption($name, $value)
  66034. {
  66035. $this->options[$name] = $value;
  66036. return $this;
  66037. }
  66038. public function disableOutput()
  66039. {
  66040. $this->outputDisabled = true;
  66041. return $this;
  66042. }
  66043. public function enableOutput()
  66044. {
  66045. $this->outputDisabled = false;
  66046. return $this;
  66047. }
  66048. public function getProcess()
  66049. {
  66050. if (0 === \count($this->prefix) && 0 === \count($this->arguments)) {
  66051. throw new LogicException('You must add() command arguments before calling getProcess().');
  66052. }
  66053. $options = $this->options;
  66054. $arguments = array_merge($this->prefix, $this->arguments);
  66055. $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
  66056. if ($this->inheritEnv) {
  66057. $env = array_replace($_ENV, $_SERVER, $this->env);
  66058. } else {
  66059. $env = $this->env;
  66060. }
  66061. $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
  66062. if ($this->outputDisabled) {
  66063. $process->disableOutput();
  66064. }
  66065. return $process;
  66066. }
  66067. }
  66068. <?php
  66069. namespace Symfony\Component\Process;
  66070. use Symfony\Component\Process\Exception\InvalidArgumentException;
  66071. class ProcessUtils
  66072. {
  66073. private function __construct()
  66074. {
  66075. }
  66076. public static function escapeArgument($argument)
  66077. {
  66078. if ('\\' === \DIRECTORY_SEPARATOR) {
  66079. if ('' === $argument) {
  66080. return escapeshellarg($argument);
  66081. }
  66082. $escapedArgument = '';
  66083. $quote = false;
  66084. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  66085. if ('"' === $part) {
  66086. $escapedArgument .= '\\"';
  66087. } elseif (self::isSurroundedBy($part, '%')) {
  66088. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  66089. } else {
  66090. if ('\\' === substr($part, -1)) {
  66091. $part .= '\\';
  66092. }
  66093. $quote = true;
  66094. $escapedArgument .= $part;
  66095. }
  66096. }
  66097. if ($quote) {
  66098. $escapedArgument = '"'.$escapedArgument.'"';
  66099. }
  66100. return $escapedArgument;
  66101. }
  66102. return "'".str_replace("'", "'\\''", $argument)."'";
  66103. }
  66104. public static function validateInput($caller, $input)
  66105. {
  66106. if (null !== $input) {
  66107. if (\is_resource($input)) {
  66108. return $input;
  66109. }
  66110. if (\is_string($input)) {
  66111. return $input;
  66112. }
  66113. if (is_scalar($input)) {
  66114. return (string) $input;
  66115. }
  66116. if (\is_object($input) && method_exists($input, '__toString')) {
  66117. @trigger_error('Passing an object as an input is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  66118. return (string) $input;
  66119. }
  66120. throw new InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
  66121. }
  66122. return $input;
  66123. }
  66124. private static function isSurroundedBy($arg, $char)
  66125. {
  66126. return 2 < \strlen($arg) && $char === $arg[0] && $char === $arg[\strlen($arg) - 1];
  66127. }
  66128. }
  66129. <?php
  66130. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  66131. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  66132. }
  66133. setlocale(LC_ALL, 'C');
  66134. require __DIR__.'/../src/bootstrap.php';
  66135. use Composer\Console\Application;
  66136. use Composer\XdebugHandler\XdebugHandler;
  66137. use Composer\Util\Platform;
  66138. use Composer\Util\ErrorHandler;
  66139. error_reporting(-1);
  66140. // Restart without Xdebug
  66141. $xdebug = new XdebugHandler('Composer');
  66142. $xdebug->check();
  66143. unset($xdebug);
  66144. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  66145. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  66146. exit(1);
  66147. }
  66148. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  66149. echo 'The iconv OR mbstring extension is required and both are missing.'
  66150. .PHP_EOL.'Install either of them or recompile php without --disable-iconv.'
  66151. .PHP_EOL.'Aborting.'.PHP_EOL;
  66152. exit(1);
  66153. }
  66154. if (function_exists('ini_set')) {
  66155. @ini_set('display_errors', '1');
  66156. // Set user defined memory limit
  66157. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  66158. @ini_set('memory_limit', $memoryLimit);
  66159. } else {
  66160. $memoryInBytes = function ($value) {
  66161. $unit = strtolower(substr($value, -1, 1));
  66162. $value = (int) $value;
  66163. switch($unit) {
  66164. case 'g':
  66165. $value *= 1024;
  66166. // no break (cumulative multiplier)
  66167. case 'm':
  66168. $value *= 1024;
  66169. // no break (cumulative multiplier)
  66170. case 'k':
  66171. $value *= 1024;
  66172. }
  66173. return $value;
  66174. };
  66175. $memoryLimit = trim(ini_get('memory_limit'));
  66176. // Increase memory_limit if it is lower than 1.5GB
  66177. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  66178. @ini_set('memory_limit', '1536M');
  66179. }
  66180. unset($memoryInBytes);
  66181. }
  66182. unset($memoryLimit);
  66183. }
  66184. Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0]));
  66185. ErrorHandler::register();
  66186. // run the command application
  66187. $application = new Application();
  66188. $application->run();
  66189. Copyright (c) Nils Adermann, Jordi Boggiano
  66190. Permission is hereby granted, free of charge, to any person obtaining a copy
  66191. of this software and associated documentation files (the "Software"), to deal
  66192. in the Software without restriction, including without limitation the rights
  66193. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  66194. copies of the Software, and to permit persons to whom the Software is furnished
  66195. to do so, subject to the following conditions:
  66196. The above copyright notice and this permission notice shall be included in all
  66197. copies or substantial portions of the Software.
  66198. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  66199. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  66200. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  66201. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  66202. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  66203. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  66204. THE SOFTWARE.
  66205. :Ÿ„¨ï³¾Sæ*-œ¾·ÉÓ›[4H­˜hÎà̺Ý~ÞeÚ� ­=“G&'Ï?œ  o5ÝwŸ²ŸJ���GBMB